Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PaingChan's avatar

Filamentphp Filter

->filters([ SelectFilter::make('school_id') ->label('School') ->options(School::pluck('name', 'id')) ->searchable(), //->preload()

                SelectFilter::make('class_level_id')
                ->label('Level')
                ->options(function () {
                    // Get the selected school_id from the filters
                    $schoolId = request()->query('tableFilters')['school_id']['value'] ?? null;
                    Log::info('Selected School ID:', ['school_id' => $schoolId]);
                    // Return empty options if no school is selected
                    if (!$schoolId) {
                        return [];
                    }
                    // Return the class levels for the selected school
                    return ClassLevel::where('school_id', $schoolId)->pluck('name', 'id');
                })
                ->searchable()
                //->preload()
            
        ]) 
        ->filtersFormColumns(3)  Filamentphp v3 why school_id is null ?
0 likes
0 replies

Please or to participate in this conversation.