whereNull('user_deleted_at')->first(); if(!$PromotionUser){ abort(402); } if(!$PromotionUser->promotion_admin->isActive() || $PromotionUser->checkOutOfStock()){ $data = [ 'promotion_user' => $PromotionUser, ]; return view('web.promotion.outofstock', $data); } PromotionCart::initYard(); $data = [ 'promotion_user' => $PromotionUser, 'shop_products' => Product::where('active', true)->whereJsonContains('show_on', ['3'])->orderBy('pos', 'ASC')->get(), 'user_payment_methods' => PaymentMethod::getDefaultAsArray()->toArray(), ]; return view('web.promotion.index', $data); } public function goto($load, $id){ $PromotionUser = PromotionUser::findOrFail($id); $data = [ 'promotion_user' => $PromotionUser, ]; if($load === 'thanksreminder'){ return view('web.promotion.thanksreminder', $data); } if($load === 'thanksorder'){ return view('web.promotion.thanksorder', $data); } if($load === 'notactive'){ return view('web.promotion.notactive', $data); } } public function store($id){ $PromotionUser = PromotionUser::findOrFail($id); $data = Request::all(); if(!isset($data['action'])){ abort(402); } if($data['action'] === 'submit-reminder-service'){ return redirect(route('web_promotion_goto', ['thanksreminder', $PromotionUser->id])); } if($data['action'] === 'submit-promotion-order'){ return redirect(route('web_promotion_goto', ['thanksorder', $PromotionUser->id])); } dd($PromotionUser); } public function load(){ $data = Request::all(); $ret = ""; $status = false; if(Request::ajax()){ if($data['action'] === 'web-show-product'){ $product = Product::find($data['id']); //current user form order $ret = view("web.promotion.show_product", compact('product', 'data'))->render(); } if($data['action'] === 'switch-free-product'){ \App\Services\PromotionCart::updateFeeProduct($data); $ret = view("web.promotion._promotion_cart", compact('data'))->render(); } if($data['action'] === 'add-shop-product'){ $data['qty'] = \App\Services\PromotionCart::updateProduct($data, true); $ret = view("web.promotion._promotion_cart", compact('data'))->render(); } if($data['action'] === 'update-shop-product'){ $data['qty'] = \App\Services\PromotionCart::updateProduct($data); $ret = view("web.promotion._promotion_cart", compact('data'))->render(); } if($data['action'] === 'remove-shop-product'){ \App\Services\PromotionCart::updateProduct($data); $data['qty'] = 0; $ret = view("web.promotion._promotion_cart", compact('data'))->render(); } if($data['action'] === 'clear-cart'){ \App\Services\PromotionCart::clearCart($data); $ret = view("web.promotion._promotion_cart", compact('data'))->render(); } if($data['action'] === 'switch-shipping'){ $ret = view("web.promotion._promotion_cart", compact('data'))->render(); } return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]); } } }