add constaint on stock

This commit is contained in:
Ludovic CANDELLIER
2022-03-07 20:17:50 +01:00
parent 6a634c10ca
commit 60acbc7939
6 changed files with 9 additions and 122 deletions

View File

@@ -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);
});
}
}