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 Zeus9mo ago
you set a ->url(), this will tell the action to actually navigate to that route
codeartisan
codeartisanOP9mo ago
I do set the action other routes work fine but customers.delete or customers.destroy redirects to the show page
toeknee
toeknee9mo ago
Why are you using a route? Why not ->action(fn($record) => $record->delete())
codeartisan
codeartisanOP9mo ago
let me try that But I need to pass the delete route name
toeknee
toeknee9mo ago
Why?
codeartisan
codeartisanOP9mo ago
because this is a livewire component I just used the filament table component
toeknee
toeknee9mo 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
codeartisanOP9mo ago
okay trying it out sir it works how best should append the notification?
codeartisan
codeartisanOP9mo 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
toeknee9mo 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
codeartisanOP9mo ago
thank you it works thank you so much
Want results from more Discord servers?
Add your server