Rinkesh
SelectFilter with relationship query
I have used SelectFilter and applying query like this but not getting selected value $acd_id inside where.
SelectFilter::make('academic_id')->label('Academic Year')->options(fn (Get $get): array => AcademicYear::all()->where('status' , 1)->pluck('month_label', 'id')->all()
)
->query(function (Builder $query, array $data): Builder {
return $query ->when( $data['value'], fn (Builder $query, $acd_id): Builder =>
$query->with('academic') ->whereHas('academic', function ( Builder $query, $acd_id ) { $query->where('academic_id','=', $acd_id ); }) ); })
return $query ->when( $data['value'], fn (Builder $query, $acd_id): Builder =>
$query->with('academic') ->whereHas('academic', function ( Builder $query, $acd_id ) { $query->where('academic_id','=', $acd_id ); }) ); })
10 replies