public function makeOrder(DeliveryRequest $request) { $this->validate($request); $orders = new Order(); $orders->address = $request->input('address'); $orders->contact = $request->input('contact'); $orders->phone = $request->input('phone'); $orders->email = $request->input('email'); $orders->sendwhen = null; $orders->created = date('Y-m-d H:i:s'); $orders->additional = $request->input('additional'); $orders->status = Order::STATUS['NEW']; $orders->totalprice = \App\Components\Cart::getInstance()->getTotalPrice(); $orders->save(); $request->except('_token'); $inserted = Order::find($orders->id); $inserted->products()->saveMany(Orderproducts::reFormatCartList()); Cart::getInstance()->clearAll(); return redirect('categories/all'); }
/** * Creates a new Order model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Order(); $session = Yii::$app->session; if ($model->load(Yii::$app->request->post())) { $model->setIsNewRecord(true); $model->createTime = date('Y-m-d H:i:s'); $model->session = $session->get('session_order'); $model->fullCost = $session->get('fullcost'); $model->save(); $fullCart = $session['cart']; $fioCart = $session['cart_fio']; if ($fullCart && $fioCart) { for ($i = 0; $i < $session->get('cards'); $i++) { $inOrder = new Inorder(); $inOrder->setIsNewRecord(true); $inOrder->orderID = $model->id; $inOrder->cardID = $session['cart'][$i]; $thisCard = Cards::find()->where(['id' => $session['cart'][$i]])->one(); $inOrder->cost = $thisCard->cost; $inOrder->fio = $session['cart_fio'][$i]; $inOrder->save(); } } $session->remove('cards'); $session->remove('session_order'); $session->remove('cart'); $session->remove('fullcost'); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionOrder() { $order = new Order(); $products = $this->_cart->getPositions(); $total = $this->_cart->getCost(); if ($order->load(\Yii::$app->request->post()) && $order->validate()) { $order->user_id = 1; $order->cart_id = "text"; if ($order->save(false)) { foreach ($products as $product) { $orderItem = new OrderItem(); $orderItem->order_id = $order->id; $orderItem->product_id = $product->id; $orderItem->price = $product->getPrice(); $orderItem->quantity = $product->getQuantity(); if (!$orderItem->save(false)) { \Yii::$app->session->addFlash('error', 'Cannot place your order. Please contact us.'); return $this->redirect('site/index'); } } } $this->_cart->removeAll(); \Yii::$app->session->addFlash('success', 'Thanks for your order. We\'ll contact you soon.'); //$order->sendEmail(); return $this->redirect('site/index'); } return $this->render('order', ['order' => $order, 'products' => $products, 'total' => $total]); }
public function actionPayment() { if (\Yii::$app->session->has('customer')) { $modelCustomer = new Customer(); $infoCustomer = $modelCustomer->getInformation($_SESSION['customer']); $modelOrder = new Order(); $modelOrderDetail = new OrderDetail(); $modelProduct = new Product(); $ids = array(); foreach ($_SESSION['cart_items'] as $id => $quantity) { array_push($ids, $id); } $products = $modelProduct->getWithIDs($ids); if (\Yii::$app->request->post()) { $modelOrder->load(\Yii::$app->request->post()); $modelOrder->save(); $orderId = $modelOrder->id; foreach ($_SESSION['cart_items'] as $id => $quantity) { $unitPrice = $modelProduct->getPrice($id) * $quantity; \Yii::$app->db->createCommand()->insert('order_detail', ['orderId' => $orderId, 'productId' => $id, 'unitPrice' => $unitPrice, 'quantity' => $quantity])->execute(); } \Yii::$app->session->remove('cart_items'); return $this->redirect(['cart/index', 'success' => 'Thanh toán thành công! Chúng tôi sẽ liên hệ bạn trong thời gian sớm nhất! Xin cảm ơn!']); } else { return $this->render('payment', ['infoCustomer' => $infoCustomer, 'modelOrder' => $modelOrder, 'products' => $products]); } } else { $this->redirect(['customer/login', 'error' => 'Vui lòng đăng nhập trước khi thanh toán']); } }
/** * Registra cualquier pedido junto con las comidas ordenadas por el usuario * * @return Response */ public function create() { // Se recuperan todas las comidas del objeto JSON $meals = \Input::get('meals'); // Creación e inicialización de un Pedido $order = new Order(); if ($order != null) { $order->customer_id = \Auth::user()->id; $order->meal_number = count($meals); $order->total = 100; $order->save(); } else { return response()->json(['success' => false, 'error' => "No se pudo crear el pedido debido a problemas en la base de datos"]); } //Registro de las comidas ordenadas en el pedido foreach ($meals as $meal) { // Creación e inicializacion de una comida $order_detail = new OrderDetail(); // Se recupera el id del pedido para tenerlo como referencia $order_detail->order_id = $order->id; $order_detail->meal_id = $meal['id']; $order_detail->day = $meal['day']; $order_detail->ubication = "Tercera"; $order_detail->delivery = "14:00"; $order_detail->save(); } return response()->json(["success" => true, 'msj' => "El pedido se ha creado"]); }
public function update(EditOrderRequest $request, Order $order) { $order->status_code_id = $request->get('status_code_id'); $order->save(); $request->session()->flash('status', 'Order status has been updated.'); return redirect()->route('AdminOrderShow', $order); }
public function postCreate() { $validator = Validator::make(Input::all(), Order::$rules); if ($validator->passes()) { $order = new Order(); $order->user_id = Auth::id(); $order->delivery_address = Input::get('delivery_address'); $order->sum = Cart::total(); $order->payment_type = Input::get('payment_type'); $order->save(); foreach (Cart::content() as $cart_item) { $order_product = new OrderProduct(); $order_product->order_id = $order->id; $order_product->product_id = $cart_item->id; $order_product->qty = $cart_item->qty; $order_product->sum = $cart_item->price; $order_product->save(); } Cart::destroy(); if ($order->payment_type == 0) { //pay card return Redirect::to('order/pay'); } return Redirect::to('cart/confirmed')->with('message', 'Заказ оформлен.'); } return Redirect::to('cart/confirm')->with('message', 'Проверьте корректность заполнения полей!')->withErrors($validator)->withInput(); }
private function create_cart() { $order = new Order(); $order->user_id = $this->id; $order->save(); $this->order_id = $order->id; $this->save(); }
/** * Creates a new Order model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Order(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->order_id]); } else { return $this->render('create', ['model' => $model]); } }
public function feedback(Request $request) { $text = view('email.feedback', $request->all())->render(); $email = Config::get('mail.from')['address']; $order = new Order(); $order->save(); $number = $order->id; $result = mail($email, "[kolizej.ru] обращение №{$number}", $text, "Content-type: text/html; charset=utf-8\r\n"); return ['success' => $result ? true : false, 'number' => $number]; }
public function proceedToCheckout($total) { $order = new Order(); $userId = Yii::$app->user->identity->id; $order->user_id = $userId; $order->address = $this->address; $order->phone_number = $this->phoneNumber; $order->total = $total; return $order->save(false) && !$this->hasErrors() ? $order : null; }
/** * Creates a new Order model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (Yii::$app->user->isGuest || Yii::$app->user->identity->user_role != 4 && Yii::$app->user->identity->user_role != 3 && Yii::$app->user->identity->user_role != 2 && Yii::$app->user->identity->user_role != 1) { return $this->goHome(); } $model = new Order(['scenario' => Order::SCENARIO_CREATE]); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->order_id]); } else { return $this->render('create', ['model' => $model]); } }
private function createAjax() { $data = Yii::$app->request->post(); $model = new Order(['scenario' => Order::SCENARIO_CREATE]); foreach ($data['Order'] as $key => $value) { $model->{$key} = $value; } if ($model->validate()) { return $model->save() ? true : ErrorHelper::errorsToString($model->errors); } else { return ErrorHelper::errorsToString($model->errors); } }
/** * 依据前台post消息创建订单 * * @param Request $request * @return \Response */ public function generateConfig(Request $request) { $validator = \Validator::make($request->all(), ['address_id' => 'required|exists:addresses,id', 'cart' => 'required']); if ($validator->fails()) { return response()->json($validator->errors()->getMessages()); } $customer = \Helper::getCustomer(); $items = $request->input('cart'); $sale = $request->input('sale', null); if ($sale != null && !$this->checkSaleCredential($customer, $sale)) { return response()->json(['success' => false, 'error_message' => '你不具有参加特卖资格!']); } $order = new Order(); $address = Address::findOrFail($request->input('address_id')); $order->initWithCustomerAndAddress($customer, $address, $sale); $order->save(); $order->addCommodities($items); $order->calculate(); $order->save(); $result = \Wechat::generatePaymentConfig($order, $customer); return response()->json(['success' => true, 'data' => ['result' => $result, 'order_id' => $order->id]]); }
public function actionIndex() { //todo redis? $user = Yii::$app->session->get('user'); if (empty($user)) { $this->goHome(); } $user = User::findOne($user->id); if ($user->account < Yii::$app->params['auctionDeposit']) { $order = Order::find()->where(['type' => Order::TYPE_AUCTION, 'user_id' => $user->id, 'status' => Order::STATUS_CREATED])->one(); if (empty($order)) { $order = new Order(); $order->user_id = $user->id; $order->serial_no = Util::composeOrderNumber(Order::TYPE_AUCTION); $order->money = Yii::$app->params['auctionDeposit']; $auction = Auction::find()->where('end_time > NOW()')->orderBy('start_time, end_time')->limit(1)->one(); $order->auction_id = $auction->id; $order->status = Order::STATUS_CREATED; $order->type = Order::TYPE_AUCTION; $order->save(); } $this->redirect('/pay/index?order_id=' . $order->serial_no); } $auctions = Auction::find()->where('end_time > NOW()')->orderBy('start_time, type')->limit(3)->all(); $auctionIds = []; foreach ($auctions as $auction) { array_push($auctionIds, $auction->id); } $topOffers = $this->getTopOfferHash($auctionIds); $myOffers = $this->getMyTopOfferHash($user->id, $auctionIds); foreach ($topOffers as $tmpId => $tmpOffer) { if (!array_key_exists($tmpId, $myOffers)) { $myTmpOffer = []; $myTmpOffer['auction_id'] = $tmpId; $myTmpOffer['top'] = 0; $myOffers[$tmpId] = $myTmpOffer; } list($myOffers[$tmpId]['rank'], $myOffers[$tmpId]['class'], $myOffers[$tmpId]['message']) = $this->composeRankInfo($tmpId, $myOffers[$tmpId]['top']); } $isInAuction = $this->isInAuction(); $hasNextAuction = $this->hasNextAuction(); $startTime = isset($auctions[0]) ? $auctions[0]->start_time : ''; $endTime = isset($auctions[0]) ? $auctions[0]->end_time : ''; $countDownTime = str_replace(' ', 'T', $isInAuction ? $endTime : $startTime); $priceStep = Yii::$app->params['auctionStep']; $lang = Util::getLanguage(); $view = $lang == 'en' ? 'auction' : 'auction-cn'; Util::setLanguage($lang); return $this->render($view, compact('auctions', 'topOffers', 'myOffers', 'startTime', 'endTime', 'isInAuction', 'hasNextAuction', 'countDownTime', 'priceStep')); }
public function request_post() { $post = Input::all(); $rules = ['name' => 'required', 'phone' => 'required', 'aid' => 'required']; $validator = Validator::make($post, $rules); if ($validator->fails()) { return redirect()->back()->with('error', $validator->errors()->all())->withInput(); } $order = new Order(); $order->name = $post['name']; $order->phone = $post['phone']; $order->aid = $post['aid']; $order->type = $post['type']; $order->save(); return redirect()->back()->with('success', trans('message.message_success_send')); }
public function createOrder(Request $request) { // get the basket $basket = $request->session()->get('basket'); // save order $order = new Order(); $order->shop_id = $request->session()->get('shop'); $order->customer_id = Auth::user()->id; $order->shipping_id = $request->shipping_id; $order->billing_id = $request->billing_id; $order->total = $basket['subtotal']; $basket['shipping'] = Address::find($request->shipping_id)->toArray(); $basket['billing'] = Address::find($request->billing_id)->toArray(); $order->basket = $basket; $order->save(); return $order; }
/** * Creates a new Order model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($build_id) { $model = new Order(); $model->build_fk = $build_id; $build = $model->getBuildFk()->one(); //$build2 = $this->findBuild($build_id); $parts = new ActiveDataProvider(['query' => $build->getParts(), 'sort' => false]); $address = $this->getAddress($build->user_fk); //$model->build_fk = $build->build_guide_id; $model->customer_fk = $build->user_fk; $model->status_fk = Order::STAT_PENDING; $model->date_of_order = date("Y-m-d H:i:s"); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->order_id]); } else { return $this->render('create', ['model' => $model, 'build' => $build, 'parts' => $parts, 'address' => $address]); } }
static function payProduct($user, $product) { $type = ["coupon_gold", 'coupon_silver', 'coupon_bronze']; $order = new Order(); $order->create_at = time(); $order->user_id = $user->id; $order->product_id = $product->id; $order->win = 0; $order->status = 0; if ($order->save()) { $user->{$type}[$product->type_coupon] -= 1; $user->save(); $product->number_of_coupons -= 1; $product->save(); return true; } return false; }
public function add($id) { $order = new Order(); $order->id_tour = $id; $order->id_user = Yii::$app->user->id; $order->name = $this->name; $order->tel = $this->tel; $order->count = $this->count; $order->email = $this->email; $order->info = $this->info; $order->date_tour = $this->date_tour; $order->date = date('Y-m-d h:m:s'); $order->status = $this->status; $tour = Tour::findOne($id); $order->id_owner = $tour->id_user; $order->tour_name = $tour->name; $order->save(false); return $order ? $order : null; }
public function index(Request $request) { $data = $request->json()->all('bags'); $payment = Payment::findOrFail($data['payment_id']); $logistics = Logistics::findOrFail($data['logistics_id']); $bags = Bag::with('stock.product')->find($data['bags']); $order = new Order(array_except($data, 'bags')); \DB::transaction(function () use($bags, $logistics, $payment, $order, $data, $request) { $order_products = []; foreach ($bags as $bag) { $order_products[] = $bag->stock->pick($bag->quantity); $bag->stock->save(); } $order->user_id = $request->user->id; $order->calc($order_products); $order->save(); $order->products()->saveMany($order_products); Bag::destroy($data['bags']); }); return response()->created($order); }
public static function todayOrder($group_id) { $order = OrderUtil::today(); if ($order == null) { $order = new Order(); $lifetime = Admin::getValue($group_id, 'vote_expires'); $time = "+10 min"; if ($lifetime->count() > 0) { $first = $lifetime->first(); $time = $first->value; } if (date("Y-m-d H:i:s A") > date("Y-m-d 10:30:00 AM")) { $order->date = date('Y-m-d H:i:s', strtotime($time)); } else { $order->date = date('Y-m-d 10:30:00'); } $order->user_id = UserUtil::nextUser($group_id)->id; $order->save(); } return $order; }
/** * Creates a new Order model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Order(); $model->load(Yii::$app->request->post()); $model->order_user_id = Yii::$app->user->identity->id; if ($model->save()) { $request = Yii::$app->request; if (isset($request->post()['Order']['order_items'])) { $items = $request->post()['Order']['order_items']; foreach ($items as $key => $val) { $order_item = new OrderItem(); $order_item->item_id = $key; $order_item->count = $val; $order_item->order_id = $model->order_id; $order_item->save(); } } return $this->redirect(['view', 'id' => $model->order_id]); } else { return $this->render('create', ['model' => $model, 'locations' => $this->getAllLocations(), 'all_menu' => $this->getAllMenu(), 'addons' => Item::find()->asArray()->where(['item_type' => Item::ADDON_TYPE])->all()]); } }
public function product_submit() { $data = \Request::input(); try { \DB::beginTransaction(); $order = new Order(); $order->product_id = $data['product_id']; $order->user_id = \Auth::user()->id; $order->quantity = $data['item_count']; $order->status = 'Inprogress'; $order->save(); // 견적서 메일 발송 //\Event::fire('order.send_mail', [$data]); \DB::commit(); } catch (exception $e) { \DB::rollback(); #return \Response::json(['result' => 'error']); } #return \Response::json(['result' => 'success']); return \Redirect()->route('order_product', 1); // 영업사원 user_id 로 변경 해야 함. }
public function handle(Requests\OrderRequest $request, Product $product, $id) { $product = $product->where('id', $id)->first(); if ($product !== null) { $quantity = 1; if ($product->countable == true) { $quantity = $request->get('quantity'); } // TODO вынести обработку steam id в отдельный класс или в Request // Нужно полученый STEAM ID проверить в зависимости от игры $steam_id = $request->get('steam_id'); $server = Server::where('id', $product->server_id)->first(); switch ($server->engine) { case 1: if (preg_match("/\\[U:1:(\\d+)\\]/", $steam_id)) { $steam_id = preg_replace("/\\[U:1:(\\d+)\\]/", "\$1", $steam_id); $A = $steam_id % 2; $B = intval($steam_id / 2); $steam_id = "STEAM_0:" . $A . ":" . $B; } break; } //======= $order = new Order(); $order->product_id = $product->id; $order->quantity = $quantity; $order->sum = intval($product->discount_price * $quantity); $order->email = $request->get('email'); $order->steam_id = $steam_id; $order->status = 0; $order->save(); $payment = new Payment(config('robokassa.login'), config('robokassa.paymentPassword'), config('robokassa.validationPassword')); $payment->setInvoiceId($order->id)->setSum($order->sum)->setDescription('Покупка ' . $product->title); return redirect($payment->getPaymentUrl()); } return redirect()->route('shop.index'); }
public function checkout() { $cartContent = Cart::instance('shopping')->content(); // dd($cart); $cartTotal = Cart::instance('shopping')->total(); $addrId = Session::get('addressId'); $address = Address::where('id', '=', $addrId)->first(); //$aa = json_encode(Input::get('prod')); // $bb = json_encode($cart); $order_total = Input::get('order_total'); $payment_method = Input::get('payment_method'); $order = new Order(); $order->user_id = Session::get('loggedinUserId'); $order->order_amt = $cartTotal; $order->pay_amt = $cartTotal; $order->cod_charges = '0'; $order->payment_method = $payment_method; $order->payment_status = '1'; $order->cart = json_encode($cartContent); $order->first_name = $address->firstname; $order->last_name = $address->lastname; $order->location = $address->address; $order->city = $address->city; $order->postcode = $address->postcode; $order->country_id = $address->country_id; $order->state_id = $address->zone_id; $order->order_status = '1'; $order->save(); //echo "Thank You"; $cart_ids = []; foreach ($cartContent as $cart) { $cart_ids[$cart->rowid] = ["prod_id" => $cart->id, "qty" => $cart->qty, "uprice" => $cart->price, "price" => $cart->subtotal, "created_at" => date('Y-m-d H:i:s')]; // dd($cart_ids[$cart->rowid]); if ($cart->options->has('sub_prod')) { $cart_ids[$cart->rowid]["sub_prod_id"] = $cart->options->sub_prod; $cart_ids[$cart->rowid]["price_saved"] = $cart->options->ysave; } else { if ($cart->options->has('combos')) { $sub_prd_ids = []; foreach ($cart->options->combos as $key => $val) { if (isset($val['sub_prod'])) { array_push($sub_prd_ids, (string) $val['sub_prod']); } } $cart_ids[$cart->id]["sub_prod_id"] = json_encode($sub_prd_ids); } } if (!empty($cart_ids)) { $order->products()->sync($cart_ids); } } return view(Config('constants.frontendCheckoutView') . '.response'); }
/** *将完成的订单信息存入数据库 */ public function actionAddorder() { // 生成b_time count price(需要查询) // // $timeoffset = 8; // echo date('y-m-d h:i:s',time()); // $order->o_id = //怎么自动生成一个id // $b_id 在AddOder 中 要验证seat的状态 $order = new Order(); $res = Yii::$app->request; $order->o_id = $this->actionGetoid(); //$order->s_id = '*****@*****.**'; $order->s_id = Yii::$app->user->id; $order->seat_id = $res->post('seat_id'); $order->b_time = date('y-m-d h:i:s', time()); $order->count = count($_SESSION["dishlist"]); $order->desc = $res->post('desc'); $order->price = $this->actionAccprice(); if ($order->validate()) { foreach ($_SESSION['dishlist'] as $dish) { $one = new Orderdish(); $one->o_id = $order->o_id; $one->d_id = $dish['dish_id']; $one->count = $dish['num']; $one->price = $dish['price']; if ($one->validate() && $one->save()) { } else { error('error'); } } $order->save(); return 'success'; } else { return 'fales'; } }
public function order(Request $request) { $formData = explode('&', $request->form); $arForm = []; foreach ($formData as $item) { $arItem = explode('=', $item); $arForm[$arItem[0]] = urldecode($arItem[1]); } $city = $request->city; $lift = $request->lift; $stage = $request->stage; $distance = $request->distance; $cart = $this->cart(); $text = view('email.mail', compact('city', 'distance', 'lift', 'stage', 'arForm', 'cart'))->render(); $email = Config::get('mail.from')['address']; $order = new Order(); $order->save(); $number = $order->id; $result = mail($email, "[kolizej.ru] заказ №{$number}", $text, "Content-type: text/html; charset=utf-8\r\n"); return ['success' => $result ? true : false, 'number' => $number]; }
public function actionCreateany() { $model = new Order(); if ($model->load(Yii::$app->request->post())) { $model->order_amount = number_format($model->number_bales * 4.5, 2, '.', ''); if ($model->save()) { return $this->redirect(['index', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } } else { $scoutlist = ArrayHelper::map(Scout::find()->all(), 'id', 'name'); return $this->render('create', ['model' => $model, 'scoutlist' => $scoutlist]); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $validationRules = ['oferta' => 'accepted', 'userID' => 'integer|required|in:' . Auth::user()->id]; $v = Validator::make($request->all(), $validationRules); if ($v->fails()) { return redirect()->route('confirmOrder', ['user_id' => Auth::user()->id])->withErrors($v->errors()); // $newRequest = Request::create('confirmOrder/'.Auth::user()->id, 'POST', [], [], [], [],['blat'=>$v->errors()]); // return Route::dispatch($newRequest)->getContent(); } $userID = $request->userID; if (Auth::user()->id == (int) $userID) { $productsByDepoArr = []; $newProductsByDepoArr = []; $orderNumbers = []; DB::transaction(function () use($userID, &$productsByDepoArr, &$orderNumbers, &$newProductsByDepoArr) { $products = ProductCart::with('product.condition', 'price.stantion')->where('user_id', $userID)->get(); foreach ($products as $productCart) { $productsByDepoArr[$productCart->price->stantion[0]->id][] = [$productCart->product->name . '( состояние - ' . $productCart->product->condition->condition . ')', $productCart->product_count, $productCart->price->price, $productCart->price->id, $productCart->product->id, $productCart->price->stantion[0]->stantion_name, $productCart->price->nds]; $productCart->price->amount -= $productCart->product_count; $productCart->price->save(); } $userCompany = User::with('firm')->where('id', $userID)->first(); $status = Status::where('is_first', Order::IS_FIRST)->first(); foreach ($productsByDepoArr as $depoID => $productsArr) { $order = new Order(); $order->status_id = $status->id; $order->user_id = $userID; $order->firm_id = $userCompany->firm->id; $order->email = Auth::user()->email; $order->save(); $orderNumbers[] = $order->id; foreach ($productsArr as $product) { $productsInOrder = new ProductsInOrder(); $productsInOrder->order_id = $order->id; $productsInOrder->product_name = $product[0]; $productsInOrder->product_price = $product[2]; $productsInOrder->product_amount = $product[1]; $productsInOrder->stantion_id = $depoID; $productsInOrder->price_id = $product[3]; $productsInOrder->product_id = $product[4]; $productsInOrder->stantion_name = $product[5]; $productsInOrder->nds = $product[6]; $productsInOrder->save(); } $newProductsByDepoArr[$order->id] = $productsArr; //Запускаем команду на формирование счета Bus::dispatch(new CreateInvoice($order, Stantion::find($depoID))); } ProductCart::where('user_id', $userID)->delete(); }); $files = Document::where('user_id', Auth::user()->id)->where(function ($query) use($orderNumbers) { foreach ($orderNumbers as $number) { $query->orWhere('file_name', 'like', '%' . Order::getDocTypeName(Order::INVOICE_TYPE) . '_' . $number . '_%'); } })->get(); $fileNames = []; foreach ($files as $file) { $fileNames[] = $file->file_name; } $messageParams = []; $messageParams['productByDepoWithOrderIdAsKey'] = $newProductsByDepoArr; // //Запускаем команду на отправку email Bus::dispatch(new SendEmailWithInvoices($messageParams, $fileNames)); // Bus::dispatch(new SendWithTanksForOrder($messageParams)); return view('orders.success', ['p' => 'purchases', 'ordersAmount' => count($productsByDepoArr)]); } else { return redirect('fatal_error')->with('alert-danger', 'Произошла ошибка в работе сайта. Мы уже исправляем эту проблему. Попробуйте через некоторое время.'); } }