Fixes on articles by sale_channel

This commit is contained in:
Ludovic CANDELLIER
2022-02-22 23:03:29 +01:00
parent 27893eaa7e
commit 5794cbb045
2 changed files with 8 additions and 7 deletions

View File

@@ -120,10 +120,10 @@ class Article extends Model implements HasMedia
return $query->has('offers');
}
public function scopeWithAvailableOffers($query)
public function scopeWithAvailableOffers($query, $sale_channel_id = false)
{
return $query->whereHas('offers', function ($query) {
$query->active();
return $query->whereHas('offers', function ($query) use ($sale_channel_id) {
$query->active()->bySaleChannel($sale_channel_id);
});
}