Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Tables Laravel Package

filament/tables

Powerful table builder for Filament admin panels. Add searchable, sortable, filterable tables with actions, bulk actions, and column types. Integrates cleanly with Eloquent and supports pagination, customization, and responsive layouts.

View on GitHub
Deep Wiki
Context7

title: Ternary filters

import AutoScreenshot from "@components/AutoScreenshot.astro"

Introduction

Ternary filters allow you to easily create a select filter which has three states - usually true, false and blank. To filter a column named is_admin to be true or false, you may use the ternary filter:

use Filament\Tables\Filters\TernaryFilter;

TernaryFilter::make('is_admin')

Using a ternary filter with a nullable column

Another common pattern is to use a nullable column. For example, when filtering verified and unverified users using the email_verified_at column, unverified users have a null timestamp in this column. To apply that logic, you may use the nullable() method:

use Filament\Tables\Filters\TernaryFilter;

TernaryFilter::make('email_verified_at')
    ->nullable()

Customizing the column used by a ternary filter

The column name used to scope the query is the name of the filter. To customize this, you may use the attribute() method:

use Filament\Tables\Filters\TernaryFilter;

TernaryFilter::make('verified')
    ->nullable()
    ->attribute('status_id')

Customizing the ternary filter option labels

You may customize the labels used for each state of the ternary filter. The true option label can be customized using the trueLabel() method. The false option label can be customized using the falseLabel() method. The blank (default) option label can be customized using the placeholder() method:

use Illuminate\Database\Eloquent\Builder;
use Filament\Tables\Filters\TernaryFilter;

TernaryFilter::make('email_verified_at')
    ->label('Email verification')
    ->nullable()
    ->placeholder('All users')
    ->trueLabel('Verified users')
    ->falseLabel('Not verified users')

Customizing how a ternary filter modifies the query

You may customize how the query changes for each state of the ternary filter, use the queries() method:

use Illuminate\Database\Eloquent\Builder;
use Filament\Tables\Filters\TernaryFilter;

TernaryFilter::make('email_verified_at')
    ->label('Email verification')
    ->placeholder('All users')
    ->trueLabel('Verified users')
    ->falseLabel('Not verified users')
    ->queries(
        true: fn (Builder $query) => $query->whereNotNull('email_verified_at'),
        false: fn (Builder $query) => $query->whereNull('email_verified_at'),
        blank: fn (Builder $query) => $query, // In this example, we do not want to filter the query when it is blank.
    )

Filtering soft-deletable records

The TrashedFilter can be used to filter soft-deleted records. It is a type of ternary filter that is built-in to Filament. You can use it like so:

use Filament\Tables\Filters\TrashedFilter;

TrashedFilter::make()
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport