change construction of articles/offers

This commit is contained in:
Ludovic CANDELLIER
2022-02-20 21:38:21 +01:00
parent 4b2c431ee9
commit ea53cb4c8a
7 changed files with 54 additions and 25 deletions

View File

@@ -64,7 +64,7 @@ class Offer extends Model
public function scopeActive($query)
{
return $query->where($this->table . '.status_id', 1);
return $query->byStatus(1)->byTariffActive();
}
public function scopeByArticle($query, $id)
@@ -77,6 +77,11 @@ class Offer extends Model
return $query->whereIn($this->table . '.article_id', $ids);
}
public function scopeByID($query, $id)
{
return $query->where($this->table . '.id', $id);
}
public function scopeByOffer($query, $id)
{
return $query->where($this->table . '.id', $id);
@@ -126,4 +131,11 @@ class Offer extends Model
$query->whereIn('tag_id', $tags);
});
}
public function scopeByTariffActive($query)
{
return $query->whereHas('tariff', function ($query) {
$query->active();
});
}
}