Debug Filament Search Query

Filament Resources allow to create quickly tables by mapping objects, it allows to add easily pretty common features like:

sortable
searchable
and more features

in this case to debug the search query we can check the List class that is created by d…


This content originally appeared on DEV Community and was authored by Ariel Mejia

Filament Resources allow to create quickly tables by mapping objects, it allows to add easily pretty common features like:

  • sortable
  • searchable
  • and more features

in this case to debug the search query we can check the List class that is created by default when a user creates a filament resource, eg:

User Resource

class UserResource extends Resource
{
    protected static ?string $model = User::class;

    public static function getPages(): array
    {
        return [
            'index' => ListUsers::route('/'),
            // ... more pages
        ];
    }
}

ListUsers

Here we can override a getFilteredTableQuery method to check the raw sql and debug the query

protected function getFilteredTableQuery(): Builder
{
    dd(parent::getFilteredTableQuery()->toRawSql());
}

Hope it is useful & Happy Coding!


This content originally appeared on DEV Community and was authored by Ariel Mejia


Print Share Comment Cite Upload Translate Updates
APA

Ariel Mejia | Sciencx (2024-06-20T06:18:20+00:00) Debug Filament Search Query. Retrieved from https://www.scien.cx/2024/06/20/debug-filament-search-query/

MLA
" » Debug Filament Search Query." Ariel Mejia | Sciencx - Thursday June 20, 2024, https://www.scien.cx/2024/06/20/debug-filament-search-query/
HARVARD
Ariel Mejia | Sciencx Thursday June 20, 2024 » Debug Filament Search Query., viewed ,<https://www.scien.cx/2024/06/20/debug-filament-search-query/>
VANCOUVER
Ariel Mejia | Sciencx - » Debug Filament Search Query. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/20/debug-filament-search-query/
CHICAGO
" » Debug Filament Search Query." Ariel Mejia | Sciencx - Accessed . https://www.scien.cx/2024/06/20/debug-filament-search-query/
IEEE
" » Debug Filament Search Query." Ariel Mejia | Sciencx [Online]. Available: https://www.scien.cx/2024/06/20/debug-filament-search-query/. [Accessed: ]
rf:citation
» Debug Filament Search Query | Ariel Mejia | Sciencx | https://www.scien.cx/2024/06/20/debug-filament-search-query/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.