Add new data in getBasket context
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user