Add new data in getBasket context
This commit is contained in:
@@ -12,11 +12,10 @@ use App\Repositories\Shop\Orders;
|
||||
|
||||
class BasketController extends Controller
|
||||
{
|
||||
|
||||
public function getPrice(Request $request)
|
||||
{
|
||||
$offer_id = $request->input('offer_id');
|
||||
$quantity = $request->input('quantity');
|
||||
$quantity = $request->input('quantity') ?? 1;
|
||||
$price = Offers::getPrice($offer_id, $quantity)->price_taxed;
|
||||
return number_format($quantity * $price, 2);
|
||||
}
|
||||
@@ -24,12 +23,11 @@ class BasketController extends Controller
|
||||
public function addBasket(Request $request)
|
||||
{
|
||||
$offer_id = $request->input('offer_id');
|
||||
$quantity = $request->input('quantity');
|
||||
$quantity = $request->input('quantity') ?? 1;
|
||||
$update = $request->input('update') ?? false;
|
||||
return Offers::addBasket($offer_id, $quantity, $update);
|
||||
}
|
||||
|
||||
|
||||
public function modalBasket($offer_id, $quantity)
|
||||
{
|
||||
$data['offer'] = Offers::getFull($offer_id)->toArray();
|
||||
@@ -41,6 +39,8 @@ class BasketController extends Controller
|
||||
{
|
||||
$data = self::init();
|
||||
$data['basket'] = Offers::getBasket();
|
||||
dump($data['basket']);
|
||||
exit;
|
||||
return view('Shop.Baskets.basket', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
use App\Traits\Model\HasComments;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
use BelongsToThrough, HasComments;
|
||||
use BelongsToThrough, HasComments, HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_offers';
|
||||
@@ -27,6 +28,26 @@ class Offer extends Model
|
||||
]);
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->article->categories();
|
||||
}
|
||||
|
||||
public function price_lists()
|
||||
{
|
||||
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id');
|
||||
}
|
||||
|
||||
public function price_list_values()
|
||||
{
|
||||
return $this->hasManyDeep(
|
||||
PriceListValue::class,
|
||||
[Tariff::class, PriceList::class],
|
||||
['id', 'tariff_id', 'price_list_id'],
|
||||
['tariff_id', 'id', 'id'],
|
||||
);
|
||||
}
|
||||
|
||||
public function tariff()
|
||||
{
|
||||
return $this->belongsTo(Tariff::class);
|
||||
@@ -37,16 +58,6 @@ class Offer extends Model
|
||||
return $this->belongsTo(Variation::class);
|
||||
}
|
||||
|
||||
public function price_lists()
|
||||
{
|
||||
return $this->hasManyThrough(PriceList::class, Tariff::class, 'id', 'tariff_id', 'tariff_id', 'id');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->article->categories();
|
||||
}
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->article->tags();
|
||||
|
||||
@@ -47,10 +47,16 @@ class Offers
|
||||
{
|
||||
$basket = ShopCart::getContent();
|
||||
// dump($basket->toArray());
|
||||
$offers = Offer::with(['variation', 'article.article_nature', 'article.image'])->whereIn('id', ShopCart::keys())->get();
|
||||
|
||||
$offers = Offer::with([
|
||||
'variation',
|
||||
'article.article_nature',
|
||||
'article.product.Specie',
|
||||
'article.image',
|
||||
])->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,
|
||||
|
||||
Reference in New Issue
Block a user