Add new search of articles
This commit is contained in:
@@ -39,7 +39,7 @@ class Offer extends Model
|
||||
|
||||
public function price_lists()
|
||||
{
|
||||
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'id', 'id');
|
||||
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
@@ -64,7 +64,7 @@ class Offer extends Model
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->byStatus(1)->byTariffActive();
|
||||
return $query->byStatus(1)->HasTariffActive();
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
@@ -132,10 +132,18 @@ class Offer extends Model
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByTariffActive($query)
|
||||
public function scopeHasTariffActive($query)
|
||||
{
|
||||
return $query->whereHas('tariff', function ($query) {
|
||||
$query->active();
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query, $sale_channel_id)
|
||||
{
|
||||
return $query->whereHas('price_lists', function ($query) use ($sale_channel_id) {
|
||||
$query->active()->bySaleChannel($sale_channel_id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user