Ejemplo n.º 1
0
 /**
  * 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', 'consumables.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
 }
Ejemplo n.º 2
0
 /**
  * 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 scopeOrderLocation($query, $order)
 {
     return $query->leftJoin('locations', 'users.location_id', '=', 'locations.id')->orderBy('locations.name', $order);
 }
Ejemplo n.º 3
0
 /**
  * Query builder scope to order on parent
  *
  * @param  Illuminate\Database\Query\Builder  $query  Query builder instance
  * @param  text                              $order    	 Order
  *
  * @return Illuminate\Database\Query\Builder          Modified query builder
  */
 public function scopeOrderParent($query, $order)
 {
     // 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);
 }
Ejemplo n.º 4
0
 /**
  * Query builder scope to order on admin user
  *
  * @param  Illuminate\Database\Query\Builder  $query  Query builder instance
  * @param  text                              $order       Order
  *
  * @return Illuminate\Database\Query\Builder          Modified query builder
  */
 public function scopeOrderAdmin($query, $order)
 {
     return $query->leftJoin('users', 'asset_maintenances.user_id', '=', 'users.id')->orderBy('users.first_name', $order)->orderBy('users.last_name', $order);
 }
Ejemplo n.º 5
0
 /**
  * Query builder scope to order on manager
  *
  * @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)
 {
     // Left join here, or it will only return results with parents
     return $query->leftJoin('users as manager', 'users.manager_id', '=', 'manager.id')->orderBy('manager.first_name', $order)->orderBy('manager.last_name', $order);
 }