Order by default location

This commit is contained in:
snipe 2018-01-24 14:27:12 -08:00
parent eddcc0fbbd
commit 1d04897b32
2 changed files with 14 additions and 0 deletions

View file

@ -244,6 +244,8 @@ class AssetsController extends Controller
break;
case 'location':
$assets->OrderLocation($order);
case 'rtd_location':
$assets->OrderRtdLocation($order);
break;
case 'status_label':
$assets->OrderStatus($order);

View file

@ -1162,6 +1162,18 @@ class Asset extends Depreciable
return $query->leftJoin('locations as asset_locations', 'asset_locations.id', '=', 'assets.location_id')->orderBy('asset_locations.name', $order);
}
/**
* Query builder scope to order on default
* @param \Illuminate\Database\Query\Builder $query Query builder instance
* @param text $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeOrderRtdLocation($query, $order)
{
return $query->leftJoin('locations as rtd_asset_locations', 'rtd_asset_locations.id', '=', 'assets.rtd_location_id')->orderBy('rtd_asset_locations.name', $order);
}
/**
* Query builder scope to order on supplier name