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

@@ -50,8 +50,8 @@ class Tariff extends Model
public function scopeByAutocomplete($query, $str)
{
return $query->where($this->table . '.name', 'LIKE', "%${str}%")
->orWhere($this->table . '.ref', 'LIKE', "${str}%")
->orWhere($this->table . '.code', 'LIKE', "${str}%");
->orWhere($this->table . '.ref', 'LIKE', "${str}%")
->orWhere($this->table . '.code', 'LIKE', "${str}%");
}
public function scopeBySaleChanel($query, $id)
@@ -67,7 +67,19 @@ class Tariff extends Model
public function scopeByOffer($query, $id)
{
return $query->whereHas('offers', function ($query) use ($id) {
$query->where('id', $id);
$query->byID($id);
});
}
public function scopeActive($query)
{
return $query->byStatus(0)->byPriceListsActive();
}
public function scopeByPriceListsActive($query)
{
return $query->whereHas('price_lists', function ($query) {
$query->active();
});
}
}