DEV Community

Ariel Mejia
Ariel Mejia

Posted on

2

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more