Courses

Filament 3 From Scratch: Practical Course

Table Filters for Select and Dates

You're reading a FREE PREVIEW of a PREMIUM course.
Summary of this lesson:
- Creating select filters
- Implementing custom date filters
- Configuring filter layouts
- Managing multiple filters

Video Version of the Lesson

[Only for premium members]

Link to the repository

[Only for premium members]

Text Version of the Lesson

Now let's return to our tables and see how to filter the data. You have already seen the searchable() for columns, but we can add a more complex global filter.

Remember, in the ProductResource, we have this array empty by default:

app/Filament/Resources/ProductResource.php:

return $table
->columns([
// ...
])
->filters([
// <- THIS ONE
])

It's time to fill it in!

You can define the filters that would appear in the top-right corner of the table.

The most simple example provided in the docs would render a checkbox filter:

->filters([
Tables\Filters\Filter::make('is_featured')
->query(fn (Builder $query): Builder => $query->where('is_featured', true))
])

You need to provide a query that would filter by that checkbox.

But in our case, we don't have a checkbox field. We have Product status with three possible options. For this case...

The full lesson is only for Premium Members.
Want to access all 24 video+text lessons of this course? (2 h 01 min)

You also get:

  • 76 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord