Delete Action Not Working

I am using a filament table component in my livewire application but the delete action instead redirects to the show details page
ActionTable::make('delete')
->label('Delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-o-trash')
->url(function ($record) {
return route('customers.delete', $record);
}),
ActionTable::make('delete')
->label('Delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-o-trash')
->url(function ($record) {
return route('customers.delete', $record);
}),
Solution:
```php ActionTable::make('delete') ->label('Delete') ->requiresConfirmation() ->color('danger')...
Jump to solution
12 Replies
Lara Zeus
Lara Zeus4mo ago
you set a ->url(), this will tell the action to actually navigate to that route
codeartisan
codeartisan4mo ago
I do set the action other routes work fine but customers.delete or customers.destroy redirects to the show page
toeknee
toeknee4mo ago
Why are you using a route? Why not ->action(fn($record) => $record->delete())
codeartisan
codeartisan4mo ago
let me try that But I need to pass the delete route name
toeknee
toeknee4mo ago
Why?
codeartisan
codeartisan4mo ago
because this is a livewire component I just used the filament table component
toeknee
toeknee4mo ago
That makes no sense to delete a record using an Action method doesn't require anything else beyond the above. Why do you feel you need to redirect? You could send a notifcation too of course to let the users know it's been deleted.
codeartisan
codeartisan4mo ago
okay trying it out sir it works how best should append the notification?
codeartisan
codeartisan4mo ago
Yeah I have notifications setup I use them during exports
ActionTable::make('delete')
->label('Delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-o-trash')
->action(function ($record) {
// Delete the record
$record->delete();
})
ActionTable::make('delete')
->label('Delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-o-trash')
->action(function ($record) {
// Delete the record
$record->delete();
})
I want to trigger it after this action
Solution
toeknee
toeknee4mo ago
ActionTable::make('delete')
->label('Delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-o-trash')
->action(function ($record) {
// Delete the record
if($record->delete()) {
Notification::make()
->title('Delete record ' . $record->id . ' successfully')
->success()
->send();
}
})
ActionTable::make('delete')
->label('Delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-o-trash')
->action(function ($record) {
// Delete the record
if($record->delete()) {
Notification::make()
->title('Delete record ' . $record->id . ' successfully')
->success()
->send();
}
})
codeartisan
codeartisan4mo ago
thank you it works thank you so much