filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
17.48k stars 2.73k forks source link

Filters Seem to ignore SoftDeleted Macros #1408

Closed adamkelso closed 2 years ago

adamkelso commented 2 years ago

Package

filament/tables

Package Version

v22.9.16

Laravel Version

v8.81.0

Livewire Version

v2.10.1

PHP Version

8.1

Bug description

First off, thank you for working on Filament. This project is awesome!

Following the documentation, it appears tables do not allow soft deleted query builders to use withTrashed or onlyTrashed macros.

The following is a the code used for my table filters array

->filters([
    Tables\Filters\Filter::make('deleted')
        ->label('Deleted')
        ->query(fn ($query) => $query->onlyTrashed()),
    Tables\Filters\Filter::make('used')
        ->query(fn ($query) => $query->whereHas('orders'))
        ->label('Used'),
    Tables\Filters\SelectFilter::make('type')
        ->options([
            'flat' => 'Flat',
            'percent' => 'Percent'
        ])
]);

The second and third filters work without issue. However, no records show when the "deleted" filter is selected, though there are more than 30 soft deleted record in the table. Any ideas what I might be doing wrong?

Steps to reproduce

No response

Relevant log output

No response

MACscr commented 2 years ago

https://filamentadmin.com/docs/2.x/admin/resources#disabling-global-scopes

adamkelso commented 2 years ago

Missed that in the docs. Thanks for pointing that out.