© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
Kaesa Lyrih

filter table column relation

How to make SelectFilter enum Columns
current_school
current_school
in table
student
student
via table
student_product
student_product
?

I want to filter this columns.
Tables\Columns\TextColumn::make('student.current_school'),
Tables\Columns\TextColumn::make('student.current_school'),

table
student
student
:
$table->enum('current_school', ['PAUD', 'TK', 'SD', 'SMP', 'SMK'])->nullable();
$table->enum('current_school', ['PAUD', 'TK', 'SD', 'SMP', 'SMK'])->nullable();


Model StudentProduct.php
 public function student()
    {
        return $this->belongsTo(Student::class, 'student_id');
    }
 public function student()
    {
        return $this->belongsTo(Student::class, 'student_id');
    }
Solution
Done solve
https://github.com/filamentphp/filament/discussions/9067#discussioncomment-7271187
 Tables\Filters\SelectFilter::make('current_school')
                    ->label('Sekolah')
                    ->options([
                        'PAUD' => 'PAUD',
                        'TK' => 'TK',
                        'SD' => 'SD',
                        'SMP' => 'SMP',
                        'SMK' => 'SMK',
                    ])->modifyQueryUsing(
                        function (Builder $query, $data) {
                            if (!$data['values']) {
                                return $query;
                            }
                            return $query->whereHas('student', function (Builder $query) use ($data) {
                                return $query->whereIn('current_school', $data['values']);
                            });
                        }
                    )
                    ->multiple(),
 Tables\Filters\SelectFilter::make('current_school')
                    ->label('Sekolah')
                    ->options([
                        'PAUD' => 'PAUD',
                        'TK' => 'TK',
                        'SD' => 'SD',
                        'SMP' => 'SMP',
                        'SMK' => 'SMK',
                    ])->modifyQueryUsing(
                        function (Builder $query, $data) {
                            if (!$data['values']) {
                                return $query;
                            }
                            return $query->whereHas('student', function (Builder $query) use ($data) {
                                return $query->whereIn('current_school', $data['values']);
                            });
                        }
                    )
                    ->multiple(),
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Table filter below column?
FilamentFFilament / ❓┊help
3y ago
Link table column to relation
FilamentFFilament / ❓┊help
3y ago
Filter table with metadata column
FilamentFFilament / ❓┊help
3y ago
Set filter form column in relation manager
FilamentFFilament / ❓┊help
3y ago