fix shipping

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 17:54:44 +02:00
parent 1675745e2a
commit b8c31f6049
36 changed files with 640 additions and 897 deletions

View File

@@ -58,9 +58,9 @@ class Category extends parentCategory
return $this->tags()->withCount('Articles');
}
public function scopeByCategory($query, $category_id)
public function scopeByCategory($query, $categoryId)
{
return $query->where('category_id', $category_id);
return $query->where('category_id', $categoryId);
}
public function scopeVisible($query)
@@ -78,28 +78,28 @@ class Category extends parentCategory
return $query->where('id', '<>', 1);
}
public function scopeInRange($query, $_lft, $_rgt)
public function scopeInRange($query, $left, $right)
{
return $query->where('_lft', '>=', $_lft)->where('_rgt', '<=', $_rgt);
return $query->where('_lft', '>=', $left)->where('_rgt', '<=', $right);
}
public function scopeHasAvailableOffers($query, $sale_channel_id = false)
public function scopeHasAvailableOffers($query, $saleChannelId = false)
{
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
$saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID();
return $query->whereHas('articles', function ($query) use ($sale_channel_id) {
$query->WithAvailableOffers($sale_channel_id);
return $query->whereHas('articles', function ($query) use ($saleChannelId) {
$query->WithAvailableOffers($saleChannelId);
});
}
public function scopeHasAvailableOffersByCategoryParent($query, $sale_channel_id = false)
public function scopeHasAvailableOffersByCategoryParent($query, $saleChannelId = false)
{
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
$saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID();
return $query->whereHas('articles', function ($query) use ($sale_channel_id) {
$query->WithAvailableOffers($sale_channel_id);
})->orWhereHas('descendants.articles', function ($query) use ($sale_channel_id) {
$query->WithAvailableOffers($sale_channel_id);
return $query->whereHas('articles', function ($query) use ($saleChannelId) {
$query->WithAvailableOffers($saleChannelId);
})->orWhereHas('descendants.articles', function ($query) use ($saleChannelId) {
$query->WithAvailableOffers($saleChannelId);
});
}
}