Error with 'multiple' Attribute in Select Input Field
Hi all,
I need help with an error that pops up when I add the 'multiple' attribute to a select input field.
Thanks for your assistance.
10 Replies
You can't use
->multiple()
with belongsTo relationhmmm , whate relationship You can use in
->multiple()
belongsToMany relation or normal field casted as array
Oke , but not work
Select::make('department_ids')
->multiple()
->preload()
->required()
->options( Department::all()->pluck("name", "id"))
])->columns(2),
public function departments() {
return $this->belongsToMany (Department::class);
}
This error has not changedyou need a pivot table, not a foreign key column
How did he do that?
please google "laravel belongs to many"
I don't mean that, I know how to do it in Larvel
What I mean is how do I do it in the column
a belongs to many relationship relies on a pivot table. not a JSON array of IDs.
remove the relationship and fix the table column to be JSON
ok i try it