Added - Order location by manager

This commit is contained in:
snipe
2018-02-21 05:09:40 -08:00
parent 0cf9cdd3b1
commit 698ea36cc2
3 changed files with 17 additions and 1 deletions
+13
View File
@@ -205,4 +205,17 @@ class Location extends SnipeModel
// Left join here, or it will only return results with parents
return $query->leftJoin('locations as parent_loc', 'locations.parent_id', '=', 'parent_loc.id')->orderBy('parent_loc.name', $order);
}
/**
* Query builder scope to order on manager name
*
* @param \Illuminate\Database\Query\Builder $query Query builder instance
* @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeOrderManager($query, $order)
{
return $query->leftJoin('users as location_user', 'locations.manager_id', '=', 'location_user.id')->orderBy('location_user.first_name', $order)->orderBy('location_user.last_name', $order);
}
}