最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to redirect after delete on DeleteAction using Laravel Filament v3 - Stack Overflow

programmeradmin1浏览0评论

Case/Scenario:

I add DeleteAction on my SettingsResource table but I got error404 after I click the confirm in the confirmation modal. AlThough I had "id" in the model but I used "key" as primary key in the settings.

REPLICATE:

Model

protected $primaryKey = 'key';

public $incrementing = false;

protected static function getRecordRouteKeyName(): string
 {
    return 'key';
 }

SettingResource

 Tables\Actions\Action::make('delete')
    ->label('Delete')
    ->color('danger')
    ->requiresConfirmation()
    ->icon('heroicon-o-trash')
    ->action(fn (Setting $record) => $record->delete())
    ->after(fn ($livewire) => $livewire->dispatch('reload'))

 public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);
    }

    protected function getListeners(): array
    {
        return [
            'reload' => '$refresh',
        ];
    }

Still stuck in error404 after delete

发布评论

评论列表(0)

  1. 暂无评论