Fixes on available offers in category childrens for building menu
This commit is contained in:
@@ -18,9 +18,9 @@ class Categorizable extends Model
|
|||||||
return $this->belongsTo(Category::class);
|
return $this->belongsTo(Category::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function articles()
|
public function article()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Article::class)->where('categorizable_type', Article::class);
|
return $this->belongsTo(Article::class, 'categorizable_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeByCategory($query, $category_id)
|
public function scopeByCategory($query, $category_id)
|
||||||
|
|||||||
@@ -36,11 +36,6 @@ class Category extends parentCategory
|
|||||||
return $this->morphedByMany(Article::class, 'categorizable');
|
return $this->morphedByMany(Article::class, 'categorizable');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ArticlesByParent()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function ArticlesTagged()
|
public function ArticlesTagged()
|
||||||
{
|
{
|
||||||
return $this->tags->articles;
|
return $this->tags->articles;
|
||||||
@@ -94,6 +89,8 @@ class Category extends parentCategory
|
|||||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||||
return $query->whereHas('articles', function ($query) use ($sale_channel_id) {
|
return $query->whereHas('articles', function ($query) use ($sale_channel_id) {
|
||||||
$query->WithAvailableOffers($sale_channel_id);
|
$query->WithAvailableOffers($sale_channel_id);
|
||||||
|
})->orWhereHas('descendants.articles', function ($query) use ($sale_channel_id) {
|
||||||
|
$query->WithAvailableOffers($sale_channel_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Categories
|
|||||||
public static function getCategoryTreeVisibles($sale_channel_id = false)
|
public static function getCategoryTreeVisibles($sale_channel_id = false)
|
||||||
{
|
{
|
||||||
// return self::getModel()->defaultOrder()->visible()->hasAvailableOffers($sale_channel_id)->get()->toTree();
|
// return self::getModel()->defaultOrder()->visible()->hasAvailableOffers($sale_channel_id)->get()->toTree();
|
||||||
return self::getModel()->defaultOrder()->visible()->get()->toTree();
|
return self::getModel()->defaultOrder()->hasAvailableOffersByCategoryParent($sale_channel_id)->visible()->get()->toTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getChildren($data, $withFolder = false)
|
public static function getChildren($data, $withFolder = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user