F
Filament9mo ago
BBB

Sortable relation...

Hello everyone! This works:
Tables\Columns\TextColumn::make('user.lastname')->sortable()
Tables\Columns\TextColumn::make('user.lastname')->sortable()
This obviously does not work:
Tables\Columns\TextColumn::make('user.full_name')->sortable()
Tables\Columns\TextColumn::make('user.full_name')->sortable()
full_name is a combination of lastname and firstname. How should I proceed? Should I create a scope since it's in a relationship? Any help? Thanks in advance!
4 Replies
awcodes
awcodes9mo ago
Sounds like you need a virtual column. It’s somewhere in the docs. Sorry I don’t have a link at the moment.
BBB
BBBOP9mo ago
Yes, I've seen this solution, but I would prefer to first filter by last name and then by first name. Thank you for your response.
awcodes
awcodes9mo ago
Well, based on what your shared you don’t have a first or last name column. So it would have to be a virtual column.
BBB
BBBOP9mo ago
Actually, I don't know what got into me... I was foolish. All I needed to do was: Tables\Columns\TextColumn::make('user.full_name') ->sortable(['firstname', 'lastname']) Thank you 🙂
Want results from more Discord servers?
Add your server