Updating a date with a Table Toggle.
Hi, I have a dateTime filed called
archived_on
. I'd like to edit this column using a toggle field in a table. Specifically, when the toggle is switched to "off", I want the date field to be set to null
, when the toggle is switched to "on", I want the field to be set to now()
. How can I go about this?Solution:Jump to solution
```
ToggleColumn::make('archived_on')
->label('Archived')
->updateStateUsing(function ($state, $record) {
$record->archived_on = $state...
2 Replies
I figured it out with some creative Googling:
Solution