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.
No description
10 Replies
MohamedSabil83
MohamedSabil833mo ago
You can't use ->multiple() with belongsTo relation
dynamite
dynamite3mo ago
hmmm , whate relationship You can use in ->multiple()
MohamedSabil83
MohamedSabil833mo ago
belongsToMany relation or normal field casted as array
dynamite
dynamite3mo ago
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 changed
Dan Harrin
Dan Harrin3mo ago
you need a pivot table, not a foreign key column
dynamite
dynamite3mo ago
How did he do that?
Dan Harrin
Dan Harrin3mo ago
please google "laravel belongs to many"
dynamite
dynamite3mo ago
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
Dan Harrin
Dan Harrin3mo ago
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
dynamite
dynamite3mo ago
ok i try it