DEV Community

Ariel Mejia
Ariel Mejia

Posted on

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 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
        ];
    }
}
Enter fullscreen mode Exit fullscreen mode

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());
}
Enter fullscreen mode Exit fullscreen mode

Hope it is useful & Happy Coding!

Top comments (0)