filter table column relation

How to make SelectFilter enum Columns current_school in table student via table student_product ? I want to filter this columns.
Tables\Columns\TextColumn::make('student.current_school'),
Tables\Columns\TextColumn::make('student.current_school'),
table 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')...
Jump to solution
1 Reply
Solution
Kaesa Lyrih
Kaesa Lyrih12mo ago
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(),
Want results from more Discord servers?
Add your server