Add new data in getBasket context
This commit is contained in:
@@ -39,8 +39,8 @@ class BasketController extends Controller
|
|||||||
{
|
{
|
||||||
$data = self::init();
|
$data = self::init();
|
||||||
$data['basket'] = Offers::getBasket();
|
$data['basket'] = Offers::getBasket();
|
||||||
dump($data['basket']);
|
// dump($data['basket']);
|
||||||
exit;
|
// exit;
|
||||||
return view('Shop.Baskets.basket', $data);
|
return view('Shop.Baskets.basket', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class Offer extends Model
|
|||||||
public function scopeWithPriceListValuesBySaleChannel($query, $sale_channel_id)
|
public function scopeWithPriceListValuesBySaleChannel($query, $sale_channel_id)
|
||||||
{
|
{
|
||||||
return $query->with([
|
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);
|
$query->bySaleChannel($sale_channel_id);
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class PriceListValue extends Model
|
|||||||
|
|
||||||
public function tariff()
|
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\Tariff' => 'tariff_id',
|
||||||
'App\Models\Shop\PriceList' => 'price_list_id',
|
'App\Models\Shop\PriceList' => 'price_list_id',
|
||||||
|
|||||||
@@ -43,8 +43,9 @@ class Offers
|
|||||||
return $offer->price_lists->first()->price_list_values->first();
|
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();
|
$basket = ShopCart::getContent();
|
||||||
// dump($basket->toArray());
|
// dump($basket->toArray());
|
||||||
$offers = Offer::with([
|
$offers = Offer::with([
|
||||||
@@ -52,11 +53,11 @@ class Offers
|
|||||||
'article.article_nature',
|
'article.article_nature',
|
||||||
'article.product.Specie',
|
'article.product.Specie',
|
||||||
'article.image',
|
'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) {
|
foreach ($basket as $item) {
|
||||||
$offer = $offers->where('id', $item->id)->first();
|
$offer = $offers->where('id', $item->id)->first();
|
||||||
dump($offer->toArray());
|
|
||||||
exit;
|
|
||||||
$article_nature = strtolower($offer->article->article_nature->name);
|
$article_nature = strtolower($offer->article->article_nature->name);
|
||||||
$data[$article_nature][] = [
|
$data[$article_nature][] = [
|
||||||
'id' => (int) $item->id,
|
'id' => (int) $item->id,
|
||||||
@@ -65,6 +66,7 @@ class Offers
|
|||||||
'price' => $item->price,
|
'price' => $item->price,
|
||||||
'variation' => $offer->variation->name,
|
'variation' => $offer->variation->name,
|
||||||
'image' => Articles::getPreviewSrc(Articles::getFullImageByArticle($offer->article)),
|
'image' => Articles::getPreviewSrc(Articles::getFullImageByArticle($offer->article)),
|
||||||
|
'latin' => $offer->article->product->specie->latin ?? false,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return $data ?? false;
|
return $data ?? false;
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<h3 style="font-size: 1.4em;">{{ $item['name'] }}</h3>
|
<h3 style="font-size: 1.4em;">{{ $item['name'] }}</h3>
|
||||||
<h4>{{ $item['article']['product']['specie']['latin'] }}</h4>
|
@if ($item['latin'] ?? false)
|
||||||
|
{{ $item['latin'] }}<br>
|
||||||
|
@endif
|
||||||
{{ $item['variation'] }}<br/>
|
{{ $item['variation'] }}<br/>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user