CheckBoxList relationships error

When i add relationships in creating checkBoxList like shown in the code below :
Forms\Components\CheckboxList::make('speakers')
                ->relationship('speakers', 'name')
                ->options(Speaker::all()->pluck('name', 'id'))
                ->required() ,

This error occure :
❌ Filament\Forms\Components\CheckboxList::getRelationship(): Return value must be of type ?Illuminate\Database\Eloquent\Relations\BelongsToMany, Illuminate\Database\Eloquent\Relations\HasMany returned
Capture.PNG
Solution
Hi,

you don't need to have following if you are using relationship

->options(Speaker::all()->pluck('name', 'id'))

Also the relationship must me BelongsToMany instead of HasMany on the relation (model)
Was this page helpful?