Added maintenance scope for ordering by supplier

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-06-14 16:11:43 -07:00
parent a57a6486e7
commit 07bc2fd742

View file

@ -162,6 +162,20 @@ class AssetMaintenance extends Model implements ICompanyableChild
* -----------------------------------------------
**/
/**
* Query builder scope to order on a supplier
*
* @param \Illuminate\Database\Query\Builder $query Query builder instance
* @param string $order Order
*
* @return \Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeOrderBySupplier($query, $order)
{
return $query->leftJoin('suppliers as suppliers_maintenances', 'asset_maintenances.supplier_id', '=', 'suppliers_maintenances.id')
->orderBy('suppliers_maintenances.name', $order);
}
/**
* Query builder scope to order on admin user
*