Merge pull request #12573 from snipe/fixes/ambiguous_model_clause

Added table aliases to fix ambiguous SQL clause
This commit is contained in:
snipe 2023-02-27 13:33:52 -08:00 committed by GitHub
commit 23ca124e94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1641,9 +1641,9 @@ class Asset extends Depreciable
*/
public function scopeOrderManufacturer($query, $order)
{
return $query->join('models', 'assets.model_id', '=', 'models.id')
->join('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id')
->orderBy('manufacturers.name', $order);
return $query->join('models as order_asset_model', 'assets.model_id', '=', 'order_asset_model.id')
->join('manufacturers as manufacturer_order', 'order_asset_model.manufacturer_id', '=', 'manufacturer_order.id')
->orderBy('manufacturer_order.name', $order);
}
/**