Select (BelongsToMany) throws error with Model::preventSilentlyDiscardingAttributes(); enabled

When I have Model::preventSilentlyDiscardingAttributes(); enabled in my AppServiceProvider using the following field results into the following error: field
Select::make('roles')
->label(__('user.relations.roles'))
->required()
->multiple()
->relationship('roles', 'name')
->preload()
->disabled(fn (?User $record) => $record?->id === auth()->id());
Select::make('roles')
->label(__('user.relations.roles'))
->required()
->multiple()
->relationship('roles', 'name')
->preload()
->disabled(fn (?User $record) => $record?->id === auth()->id());
error
Add fillable property [roles] to allow mass assignment on [App\Models\User].
Add fillable property [roles] to allow mass assignment on [App\Models\User].
Solution:
hmmm
Jump to solution
5 Replies
Solution
Dan Harrin
Dan Harrin2y ago
hmmm
Dan Harrin
Dan Harrin2y ago
try putting disabled() before relationship() or, after disabled(), put dehydrated(false)
Proculair B.V.
Proculair B.V.OP17mo ago
This worked. Could you explain why? Is there a specific order I should use?
Dan Harrin
Dan Harrin17mo ago
essentially, take a look inside disabled() and relationship() they both set dehydrated() but whichever one comes last overwrites the other a little bit of a bug
Proculair B.V.
Proculair B.V.OP17mo ago
Ah check, thank you for the prompt response V3 is lit af man
Want results from more Discord servers?
Add your server