데이터베이스에 카운티 배열을 저장하려고합니다.선택 필드의 배열 저장
<select size="5" name="county[]" multiple class="form-control-2">
<option value="" selected="" disabled="">All Counties</option>
@if (isset($counties))
@foreach ($counties as $c)
<option value="{{ $c->name }}">{{ $c->name }}</option>
@endforeach
@endif
내 컨트롤러는 다음과 같습니다 : 여기 내 블레이드의
// Store the property Alert
public function propertyAlert(PropertyAlertRequest $request)
{
$action = PropertySubscribe::create($request->all());
$action = PropertySubscribe::create([
$action->county = Input::get('county'),
]);
$action->save();
notify()->flash('Registered!', 'success', ['text' => 'You have now been registered.']);
return back();
}
나는 점점 오전 오류는 다음과 같습니다
는preg_replace(): Parameter mismatch, pattern is a string while replacement is an array
는 사람이 나에게 내가 무엇을 이해하는 데 도움이 잘못하고있는거야? 배열로 보내고 dd가 값을 성공적으로 표시하고 있습니다. 배열 항목을 foreach해야합니까?
foreach(Input::get('county') as $county)
{
PropertySubscribe::create([
$action->county = $county,
]);
}
이유는 의존성 삽입 (Dependency Injection)와 외관을 믹스 : 당신의
select multiple
이 시도하기 때문에 – Devon