© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
8 replies
ericmp #2

How to sort TextColumn by relationship date attribute?

Im trying it in 2 diff ways, both doesnt work:
Tables\Columns\TextColumn::make('ticketingRateGamesPivot.game.game_date')
    ->label(__('Game date'))
    ->date('d/m/Y H:i')
    ->sortable() // <- first way
    // second way:
    // ->sortable(query: function (Builder $query, string $direction): Builder {
    //     return $query->whereHas('ticketingRateGamesPivot', function ($q) use ($direction) {
    //         $q->whereHas('game', function ($q2) use ($direction) {
    //             $q2->orderBy('game_date', $direction);
    //         });
    //     });
    // })
Tables\Columns\TextColumn::make('ticketingRateGamesPivot.game.game_date')
    ->label(__('Game date'))
    ->date('d/m/Y H:i')
    ->sortable() // <- first way
    // second way:
    // ->sortable(query: function (Builder $query, string $direction): Builder {
    //     return $query->whereHas('ticketingRateGamesPivot', function ($q) use ($direction) {
    //         $q->whereHas('game', function ($q2) use ($direction) {
    //             $q2->orderBy('game_date', $direction);
    //         });
    //     });
    // })


* not using admin panel

in first way i get this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ticketing_rate_games.game_id' in 'where clause'
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ticketing_rate_games.game_id' in 'where clause'


in second way:
doesnt crash but it just doesnt sort it
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

Sort by Attribute
FilamentFFilament / ❓┊help
3y ago
How to sort table by relationship?
FilamentFFilament / ❓┊help
15mo ago
Sort by pivot date
FilamentFFilament / ❓┊help
2y ago
Sortable - Sort by far relationship
FilamentFFilament / ❓┊help
3y ago