From cf56f70b3a7f04a364e959b05c1318413903b8e5 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 3 Nov 2017 13:28:57 -0700 Subject: [PATCH] Added table alias for sorting --- app/Models/Asset.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index bcb702341b..578a776371 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -1085,7 +1085,7 @@ class Asset extends Depreciable */ public function scopeOrderLocation($query, $order) { - return $query->leftJoin('locations', 'locations.id', '=', 'assets.rtd_location_id')->orderBy('locations.name', $order); + return $query->leftJoin('locations as asset_locations', 'asset_locations.id', '=', 'assets.rtd_location_id')->orderBy('asset_locations.name', $order); } @@ -1099,7 +1099,7 @@ class Asset extends Depreciable */ public function scopeOrderSupplier($query, $order) { - return $query->leftJoin('suppliers', 'assets.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order); + return $query->leftJoin('suppliers as suppliers_assets', 'assets.supplier_id', '=', 'suppliers_assets.id')->orderBy('suppliers_assets.name', $order); } /**