© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
vahnmarty

sortable() in second-level relationship

Currently, this resource is using ApplicationStatus model.

Tables\Columns\TextColumn::make("application.student.first_name")
                    ->label("Student First Name")
                    ->searchable()
                    ->sortable(query: function (Builder $query, string $direction): Builder {
                        return $query->whereHas('application.student', function($sQuery) use ($direction) {
                            return $sQuery->orderBy('first_name', $direction);
                        });
                    }),
Tables\Columns\TextColumn::make("application.student.first_name")
                    ->label("Student First Name")
                    ->searchable()
                    ->sortable(query: function (Builder $query, string $direction): Builder {
                        return $query->whereHas('application.student', function($sQuery) use ($direction) {
                            return $sQuery->orderBy('first_name', $direction);
                        });
                    }),


Since the default sortable() is not working, so I had to customize the query to it. However, the one I made is not working.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Second level filtering in relationship manager
FilamentFFilament / ❓┊help
3y ago
Sortable - Sort by far relationship
FilamentFFilament / ❓┊help
3y ago
2 level relationship manager
FilamentFFilament / ❓┊help
2y ago
SelectFilter by 2 level relationship
FilamentFFilament / ❓┊help
2y ago