F
Filament2y ago
Wint

How can I know which was changes on a Select field using relationship()?

My edit form inside the resource is simple, using the relationship() function for a BelongsToMany relationship Forms\Components\MultiSelect::make('handle_departments') ->relationship('handle_departments', 'name') I'm trying to create a history record after user made changes on the relationship, but couldn't get the information about the changes. I looked into the EditRecord's lifecycle and seems it's can only be retrieved in beforeValidate hook So, how can I know the old values and new values of this relationship in this hook? I'm thinking about creating a hidden field to get the values, do you have any other suggestion?
2 Replies
Dan Harrin
Dan Harrin2y ago
the reason why it isnt dehydrated is so the model doesnt attempt to save it as a normal column, as we save relationships separately to the pivot table you could make the select dehydrated() or use a model observer which gives you access to the relationship itself
Wint
WintOP2y ago
Ah yes, we could observe the pivot table. Thank you very much.
Want results from more Discord servers?
Add your server