How to put action on toggleColumn?
Is it possible to do like this? I want to use the toggle to block user the case is the
blocked_at = timestamp
blocked_by = unsignedBigInt
blocked_at = timestamp
blocked_by = unsignedBigInt
Tables\Columns\ToggleColumn::make('blocked_at')
->label('Block')
->sortable()
->onColor('success')
->offColor('danger')
->action(function ($record, $state) {
$blocked_at = $state ? now() : null;
$blocked_by = $state ? auth()->id() : null;
$record->update([
'blocked_at' => $blocked_at,
'blocked_by' => $blocked_by,
]);
}), Tables\Columns\ToggleColumn::make('blocked_at')
->label('Block')
->sortable()
->onColor('success')
->offColor('danger')
->action(function ($record, $state) {
$blocked_at = $state ? now() : null;
$blocked_by = $state ? auth()->id() : null;
$record->update([
'blocked_at' => $blocked_at,
'blocked_by' => $blocked_by,
]);
}),