The documentation says to use the --soft-deletes
flag when generating the resource:
php artisan make:filament-resource Customer --soft-deletes
Import the scope:
use Illuminate\Database\Eloquent\SoftDeletingScope;
Add Table filters and actions related to soft deletes:
public static function table(Table $table): Table{ return $table ->columns([ // ... ]) ->filters([ Tables\Filters\TrashedFilter::make(), ]) ->actions([ // ... ]) ->bulkActions([ Tables\Actions\RestoreBulkAction::make(), Tables\Actions\ForceDeleteBulkAction::make(), ]);}
Add this method to the resource. It modifies the query to include soft deleted records:
public static function getEloquentQuery(): Builder{ return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]);}
No comments yet…