I am trying to store an array of counties in my database. Here's my blade:
<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
and my controller is:
// 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();
}
and the error I am getting is:
preg_replace(): Parameter mismatch, pattern is a string while replacement is an array
Can anyone help me understand what I am doing wrong? I am sending it as an array and the dd is showing the values successfully. Do I need to foreach on the array items?