© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
πTeR

How can I sort a table using a relationship?

In a column I have this relationship:

        return $table
            ->columns([
                Tables\Columns\TextColumn::make('enterprise.name')
                    ->label('Empreendimento')
                    ->sortable()
                    ->searchable(),
         ...
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('enterprise.name')
                    ->label('Empreendimento')
                    ->sortable()
                    ->searchable(),
         ...


How can I apply a default sort?

I try it, but this is not work!
            ->defaultSort(function ($query, $direction) {
                $query->orderBy('enterprise.name');
            })
            ->defaultSort(function ($query, $direction) {
                $query->orderBy('enterprise.name');
            })
Solution
->defaultSort('enterprise.name')
->defaultSort('enterprise.name')
Jump to solution
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

Table relationship sort error.
FilamentFFilament / ❓┊help
2y ago
How to sort table by relationship?
FilamentFFilament / ❓┊help
15mo ago
How can I sort a table on a custom page?
FilamentFFilament / ❓┊help
3y ago
How can I sort by value string on table?
FilamentFFilament / ❓┊help
16mo ago