https://twill.io logo
Hello, <@479379745856028705> the function example ...
# ❓questions
n
Hello, @ifox the function example you sent a few days ago, is giving
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user.name' in 'order clause'
error when clicking on the name to order it.
Copy code
public function order($query, array $orders = [])
    {
        if (array_key_exists('user_name', $orders)) {
            $direction = $orders['user_name'];

            unset($orders['user_name']);

            $query->with('user')->orderBy('user.name');
        }

        return parent::order($query, $orders);
    }
Its complaining about the
user.name
field, I have tried
user_name
and
name
there, but its the same. The
$indexColumns
array looks like this
Copy code
'Name' => [
            'title' => 'Name',
            'field' => 'user_name',
            'sort' => true,
        ],