F
Filament14mo ago
Mauro T

Filter belongsToMany relationmanager

When creating a filter to allow filtering by the student's status in each commission, it is correctly listed in the select, but it doesn't work when filtering, any ideas? Model Commission: public function statuses(){ return $this->belongsToMany('App\Models\Status', 'commission_student_status')->withPivot('student_id'); } public function status() { return $this->hasOneThrough( 'App\Models\Status', 'App\Models\CommissionStudentStatus', 'commission_id', 'id', 'id', 'status_id' ); } Model Student: public function statuses(){ return $this->belongsToMany('App\Models\Status', 'commission_student_status'); } public function status(){ return $this->hasOneThrough( 'App\Models\Status', 'App\Models\CommissionStudentStatus', 'student_id', 'id', 'id', 'status_id' ); } CommissionsRelationManager in Student class CommissionsRelationManager extends RelationManager { protected static string $relationship = 'commissions'; public function table(Table $table): Table { return $table ->recordTitleAttribute('course.title') ->heading('Comisiones') ->columns([ Tables\Columns\TextColumn::make('status.status') ->label('Estado') ->searchable() ->toggleable(isToggledHiddenByDefault: false), ]) ->filters([ SelectFilter::make('modality') ->relationship('modality', 'modality') ->multiple() ->label('Modalidades'), SelectFilter::make('status') ->relationship('statuses', 'status') ->multiple() ->preload() ->label('Estados'), ]) } }
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server