mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Fixed bug where sorting by company name in Users API did not work
Fixes [ch9200]
This commit is contained in:
parent
b6d2392303
commit
c5a23e8f5e
|
@ -23,6 +23,7 @@ class Handler extends ExceptionHandler
|
||||||
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
|
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
|
||||||
\Illuminate\Session\TokenMismatchException::class,
|
\Illuminate\Session\TokenMismatchException::class,
|
||||||
\Illuminate\Validation\ValidationException::class,
|
\Illuminate\Validation\ValidationException::class,
|
||||||
|
\Intervention\Image\Exception\NotSupportedException::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,6 +100,9 @@ class UsersController extends Controller
|
||||||
case 'department':
|
case 'department':
|
||||||
$users = $users->OrderDepartment($order);
|
$users = $users->OrderDepartment($order);
|
||||||
break;
|
break;
|
||||||
|
case 'company':
|
||||||
|
$users = $users->OrderCompany($order);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$allowed_columns =
|
$allowed_columns =
|
||||||
[
|
[
|
||||||
|
|
|
@ -549,4 +549,17 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||||
{
|
{
|
||||||
return $query->leftJoin('departments as departments_users', 'users.department_id', '=', 'departments_users.id')->orderBy('departments_users.name', $order);
|
return $query->leftJoin('departments as departments_users', 'users.department_id', '=', 'departments_users.id')->orderBy('departments_users.name', $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query builder scope to order on company
|
||||||
|
*
|
||||||
|
* @param Illuminate\Database\Query\Builder $query Query builder instance
|
||||||
|
* @param text $order Order
|
||||||
|
*
|
||||||
|
* @return Illuminate\Database\Query\Builder Modified query builder
|
||||||
|
*/
|
||||||
|
public function scopeOrderCompany($query, $order)
|
||||||
|
{
|
||||||
|
return $query->leftJoin('companies as companies_user', 'users.company_id', '=', 'companies_user.id')->orderBy('companies_user.name', $order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue