Added - Order location by manager
This commit is contained in:
parent
0cf9cdd3b1
commit
698ea36cc2
3 changed files with 17 additions and 1 deletions
|
@ -60,6 +60,9 @@ class LocationsController extends Controller
|
||||||
case 'parent':
|
case 'parent':
|
||||||
$locations->OrderParent($order);
|
$locations->OrderParent($order);
|
||||||
break;
|
break;
|
||||||
|
case 'manager':
|
||||||
|
$locations->OrderManager($order);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$locations->orderBy($sort, $order);
|
$locations->orderBy($sort, $order);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -205,4 +205,17 @@ class Location extends SnipeModel
|
||||||
// Left join here, or it will only return results with parents
|
// 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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class LocationPresenter extends Presenter
|
||||||
],[
|
],[
|
||||||
"field" => "manager",
|
"field" => "manager",
|
||||||
"searchable" => false,
|
"searchable" => false,
|
||||||
"sortable" => false,
|
"sortable" => true,
|
||||||
"switchable" => true,
|
"switchable" => true,
|
||||||
"title" => trans('admin/users/table.manager'),
|
"title" => trans('admin/users/table.manager'),
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
|
|
Loading…
Add table
Reference in a new issue