fix on shelve with available offers

This commit is contained in:
Ludovic CANDELLIER
2022-04-25 21:59:53 +02:00
parent 328d791b87
commit c9bf18d87d
4 changed files with 68 additions and 2 deletions

View File

@@ -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);
});
}
}