fix on shelve with available offers
This commit is contained in:
@@ -36,11 +36,21 @@ class Category extends parentCategory
|
||||
return $this->morphedByMany(Article::class, 'categorizable');
|
||||
}
|
||||
|
||||
public function ArticlesByParent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function ArticlesTagged()
|
||||
{
|
||||
return $this->tags->articles;
|
||||
}
|
||||
|
||||
public function categorizables()
|
||||
{
|
||||
return $this->hasMany(Categorizable::class);
|
||||
}
|
||||
|
||||
public function countArticlesTagged()
|
||||
{
|
||||
return $this->tags()->withCount('Articles');
|
||||
@@ -66,6 +76,11 @@ class Category extends parentCategory
|
||||
return $query->where('id', '<>', 1);
|
||||
}
|
||||
|
||||
public function scopeInRange($query, $_lft, $_rgt)
|
||||
{
|
||||
return $query->where('_lft', '>=', $_lft)->where('_rgt', '<=', $_rgt);
|
||||
}
|
||||
|
||||
public function scopeHasAvailableOffers($query, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
@@ -73,4 +88,12 @@ class Category extends parentCategory
|
||||
$query->WithAvailableOffers($sale_channel_id);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeHasAvailableOffersByCategoryParent($query, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
return $query->whereHas('articles', function ($query) use ($sale_channel_id) {
|
||||
$query->WithAvailableOffers($sale_channel_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user