Add display of shelve
This commit is contained in:
@@ -78,9 +78,9 @@ class Article extends Model implements HasMedia
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
return $query->whereHas('categories', function ($query) use ($category_id) {
|
||||
return $category_id ? $query->whereHas('categories', function ($query) use ($category_id) {
|
||||
$query->where('id', $category_id);
|
||||
});
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
public function scopeByProduct($query, $model)
|
||||
@@ -93,6 +93,20 @@ class Article extends Model implements HasMedia
|
||||
return $query->where($this->table . '.product_id', $model_id);
|
||||
}
|
||||
|
||||
public function scopeByTag($query, $tag_id)
|
||||
{
|
||||
return $tag_id ? $query->whereHas('tags', function ($query) use ($tag_id) {
|
||||
$query->where('id', $tag_id);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
public function scopeByTags($query, $tags)
|
||||
{
|
||||
return $tags ? $query->whereHas('tags', function ($query) use ($tags) {
|
||||
$query->whereIn('id', $tags);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
public function scopeWithOffers($query)
|
||||
{
|
||||
return $query->has('offers');
|
||||
|
||||
@@ -112,5 +112,4 @@ class Offer extends Model
|
||||
$query->whereIn('tag_id', $tags);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,14 +22,10 @@ class PriceListValue extends Model
|
||||
|
||||
public function tariff()
|
||||
{
|
||||
return $this->belongsToThrough(
|
||||
'App\Models\Shop\Tariff',
|
||||
'App\Models\Shop\PriceList',
|
||||
null,
|
||||
'',
|
||||
return $this->belongsToThrough('App\Models\Shop\Tariff', 'App\Models\Shop\PriceList', null, '',
|
||||
[
|
||||
'App\Models\Shop\Tariff' => 'tariff_id',
|
||||
'App\Models\Shop\PriceList' => 'price_list_id'
|
||||
'App\Models\Shop\PriceList' => 'price_list_id',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user