Check for array

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-08-29 21:01:48 +01:00
parent 76301bc30d
commit 4e4930ba62

View file

@ -1811,7 +1811,9 @@ class Asset extends Depreciable
public function scopeInCategory($query, $category_id) public function scopeInCategory($query, $category_id)
{ {
return $query->join('models as category_models', 'assets.model_id', '=', 'category_models.id') return $query->join('models as category_models', 'assets.model_id', '=', 'category_models.id')
->join('categories', 'category_models.category_id', '=', 'categories.id')->whereIn('category_models.category_id', $category_id); ->join('categories', 'category_models.category_id', '=', 'categories.id')
->whereIn('category_models.category_id', (!is_array($category_id) ? explode(',',$category_id): $category_id));
//->whereIn('category_models.category_id', $category_id);
} }
/** /**
@ -1825,7 +1827,7 @@ class Asset extends Depreciable
public function scopeByManufacturer($query, $manufacturer_id) public function scopeByManufacturer($query, $manufacturer_id)
{ {
return $query->join('models', 'assets.model_id', '=', 'models.id') return $query->join('models', 'assets.model_id', '=', 'models.id')
->join('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id')->whereIn('models.manufacturer_id', $manufacturer_id); ->join('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id')->whereIn('models.manufacturer_id', (!is_array($manufacturer_id) ? explode(',',$manufacturer_id): $manufacturer_id));
} }