Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lutkabe's avatar

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!

0 likes
0 replies

Please or to participate in this conversation.