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


Since the default sortable() is not working, so I had to customize the query to it. However, the one I made is not working.
Was this page helpful?