add constaint on stock
This commit is contained in:
@@ -123,7 +123,7 @@ class Article extends Model implements HasMedia
|
||||
public function scopeWithAvailableOffers($query, $sale_channel_id = false)
|
||||
{
|
||||
return $query->whereHas('offers', function ($query) use ($sale_channel_id) {
|
||||
$query->active()->bySaleChannel($sale_channel_id);
|
||||
$query->active()->byStockAvailable()->bySaleChannel($sale_channel_id);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,11 @@ class Offer extends Model
|
||||
return $query->where($this->table . '.variation_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStockAvailable($query)
|
||||
{
|
||||
return $query->where($this->table . '.stock_current', '>', 0);
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $article_nature_id)
|
||||
{
|
||||
return $query->whereHas('article.article_nature', function ($query) use ($article_nature_id) {
|
||||
@@ -145,5 +150,4 @@ class Offer extends Model
|
||||
$query->active()->bySaleChannel($sale_channel_id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user