diff --git a/app/Http/Controllers/Shop/BasketController.php b/app/Http/Controllers/Shop/BasketController.php index 8a579d0a..214f6caa 100644 --- a/app/Http/Controllers/Shop/BasketController.php +++ b/app/Http/Controllers/Shop/BasketController.php @@ -39,8 +39,8 @@ class BasketController extends Controller { $data = self::init(); $data['basket'] = Offers::getBasket(); - dump($data['basket']); - exit; + // dump($data['basket']); + // exit; return view('Shop.Baskets.basket', $data); } diff --git a/app/Models/Shop/Offer.php b/app/Models/Shop/Offer.php index 8846ca59..b62e10d0 100644 --- a/app/Models/Shop/Offer.php +++ b/app/Models/Shop/Offer.php @@ -174,7 +174,7 @@ class Offer extends Model public function scopeWithPriceListValuesBySaleChannel($query, $sale_channel_id) { return $query->with([ - 'price_lists.price_list_values' => function($query) use ($sale_channel_id) { + 'price_list_values' => function($query) use ($sale_channel_id) { $query->bySaleChannel($sale_channel_id); }, ]); diff --git a/app/Models/Shop/PriceListValue.php b/app/Models/Shop/PriceListValue.php index 96acd65f..ecab9985 100644 --- a/app/Models/Shop/PriceListValue.php +++ b/app/Models/Shop/PriceListValue.php @@ -22,7 +22,7 @@ class PriceListValue extends Model public function tariff() { - return $this->belongsToThrough('App\Models\Shop\Tariff', 'App\Models\Shop\PriceList', null, '', + return $this->belongsToThrough(Tariff::class, PriceList::class, null, '', [ 'App\Models\Shop\Tariff' => 'tariff_id', 'App\Models\Shop\PriceList' => 'price_list_id', diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php index 00c13e5f..03466b71 100644 --- a/app/Repositories/Shop/Offers.php +++ b/app/Repositories/Shop/Offers.php @@ -43,8 +43,9 @@ class Offers return $offer->price_lists->first()->price_list_values->first(); } - public static function getBasket() + public static function getBasket($sale_channel_id = false) { + $sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID(); $basket = ShopCart::getContent(); // dump($basket->toArray()); $offers = Offer::with([ @@ -52,11 +53,11 @@ class Offers 'article.article_nature', 'article.product.Specie', 'article.image', - ])->whereIn('id', ShopCart::keys())->get(); + 'price_lists.price_list_values', + ])->withPriceListsBySaleChannel($sale_channel_id) + ->whereIn('id', ShopCart::keys())->get(); foreach ($basket as $item) { $offer = $offers->where('id', $item->id)->first(); - dump($offer->toArray()); - exit; $article_nature = strtolower($offer->article->article_nature->name); $data[$article_nature][] = [ 'id' => (int) $item->id, @@ -65,6 +66,7 @@ class Offers 'price' => $item->price, 'variation' => $offer->variation->name, 'image' => Articles::getPreviewSrc(Articles::getFullImageByArticle($offer->article)), + 'latin' => $offer->article->product->specie->latin ?? false, ]; } return $data ?? false; diff --git a/resources/views/Shop/Baskets/partials/article.blade.php b/resources/views/Shop/Baskets/partials/article.blade.php index eaac5da1..9813fbfa 100644 --- a/resources/views/Shop/Baskets/partials/article.blade.php +++ b/resources/views/Shop/Baskets/partials/article.blade.php @@ -4,7 +4,9 @@

{{ $item['name'] }}

-

{{ $item['article']['product']['specie']['latin'] }}

+ @if ($item['latin'] ?? false) + {{ $item['latin'] }}
+ @endif {{ $item['variation'] }}