Jul 3, 2021
0
Level 1
How to make an accessor field sortable?
If I have the following accessor in User model:
public function getFullNameAttribute()
{
return "{$this->first_name} {$this->last_name}";
}
and use it in a Nova resource like:
Text::make('Full Name', 'full_name')->sortable(),
it is displayed on the index page but the sort action throws a SQL exception:
Column not found. 1054 Unknown column 'full_name' in 'order clause' (SQL: select * from 'users' order by 'full_name' asc ...)
Is there any way to make this working?
Thanks!
Please or to participate in this conversation.