zones is an array, you can't save it in Label.
$label = Label::create($request->except('zones'));
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I think this is issue is related with validation,
I have a STORE REQUEST on request folder to the validation with this rule
public function rules()
{
return [
'zones' => 'required|array|min:1'
];
}
I have one the controller for the CRUD, on the create method:
public function create()
{
return view('labels.create', ['countries' => Country::orderBy('name')->pluck('name', 'id')]);
}
I have a create view file with a form:
@foreach($countries as $id => $name)
<div>
<label>
<input type="checkbox" name="zones[]" value="{{ $id }}">
{{ $name }}
</label>
</div>
@endforeach
I got this error http://flareapp.io/share/W7zjpbl7
if I remove this rule 'zones' => 'required|array|min:1' everything works fine, the form save without problems, I need that checkboxes as required.
Any help? thank you
zones is an array, you can't save it in Label.
$label = Label::create($request->except('zones'));
Please or to participate in this conversation.