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);
    //         });
    //     });
    // })


  • 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'


in second way:
doesnt crash but it just doesnt sort it
Was this page helpful?