mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add user sorting
This commit is contained in:
parent
b71f1c0e37
commit
0b2b3b2ab7
@ -110,12 +110,15 @@ class TaskFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
|
||||
if ($sort_col[0] == 'client_id') {
|
||||
return $this->builder->orderBy(\App\Models\Client::select('name')
|
||||
->whereColumn('clients.id', 'tasks.client_id'), $sort_col[1]);
|
||||
}
|
||||
|
||||
if ($sort_col[0] == 'user_id') {
|
||||
return $this->builder->orderBy(\App\Models\User::select('first_name')
|
||||
->whereColumn('users.id', 'tasks.user_id'), $sort_col[1]);
|
||||
}
|
||||
|
||||
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class TaskTransformer extends EntityTransformer
|
||||
'client',
|
||||
'status',
|
||||
'project',
|
||||
'user',
|
||||
];
|
||||
|
||||
public function includeDocuments(Task $task)
|
||||
@ -45,6 +46,18 @@ class TaskTransformer extends EntityTransformer
|
||||
return $this->includeCollection($task->documents, $transformer, Document::class);
|
||||
}
|
||||
|
||||
public function includeUser(Task $task): ?Item
|
||||
{
|
||||
$transformer = new UserTransformer($this->serializer);
|
||||
|
||||
if (!$task->user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->includeItem($task->user, $transformer, User::class);
|
||||
}
|
||||
|
||||
|
||||
public function includeClient(Task $task): ?Item
|
||||
{
|
||||
$transformer = new ClientTransformer($this->serializer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user