Advanced toggle column to a table

ToggleColumn::make('collected')
ToggleColumn::make('collected')
My database table doesn't have an is_collected column. Instead, I have a collected_by column (foreign key to a collectors table) and a collected_at timestamp. How can I customize the ToggleColumn to update the collected_by and collected_at columns when toggled on, ideally setting collected_by to auth()->user()->collector_id? By default the toggle sets is_collected to 1 but that column does not exist.
2 Replies
Positiverain
Positiverain4mo ago
That didn't help. Only thing that's close enough was "updateStateUsing()" method, but I am unable to change the state afterwards. The state stays 'null'.