belongsTo('App\Models\Shop\PriceGeneric'); } public function scopeByPriceGeneric($query, $id) { return $query->where('price_generic_id', $id); } public function scopeByQuantity($query, $quantity) { return $query->orderBy('quantity', 'desc')->where('quantity', '<', $quantity)->first(); } }