当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::save方法代码示例

本文整理汇总了PHP中app\models\Order::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::save方法的具体用法?PHP Order::save怎么用?PHP Order::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Order的用法示例。


在下文中一共展示了Order::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeOrder

 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');
 }
开发者ID:barricade86,项目名称:laravel,代码行数:20,代码来源:Orders.php

示例2: actionCreate

 /**
  * 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]);
     }
 }
开发者ID:arsik,项目名称:xfit,代码行数:38,代码来源:OrderController.php

示例3: actionOrder

 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]);
 }
开发者ID:absol3112,项目名称:sonneboutique,代码行数:28,代码来源:CartController.php

示例4: actionPayment

 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']);
     }
 }
开发者ID:royutoan,项目名称:pianodanang,代码行数:30,代码来源:CartController.php

示例5: create

 /**
  * 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"]);
 }
开发者ID:miguellgt,项目名称:proyecto-x-mvp,代码行数:33,代码来源:OrderController.php

示例6: update

 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);
 }
开发者ID:catchup-forks,项目名称:gameshop,代码行数:7,代码来源:OrderController.php

示例7: postCreate

 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();
 }
开发者ID:venomir,项目名称:tc,代码行数:27,代码来源:OrderController.php

示例8: create_cart

 private function create_cart()
 {
     $order = new Order();
     $order->user_id = $this->id;
     $order->save();
     $this->order_id = $order->id;
     $this->save();
 }
开发者ID:nkiermaier,项目名称:laravel_ecommerce,代码行数:8,代码来源:User.php

示例9: actionCreate

 /**
  * 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]);
     }
 }
开发者ID:vab777,项目名称:marts.id_be,代码行数:14,代码来源:OrderController.php

示例10: feedback

 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];
 }
开发者ID:pechatny,项目名称:kolizej,代码行数:10,代码来源:PagesController.php

示例11: proceedToCheckout

 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;
 }
开发者ID:andrey3,项目名称:shop,代码行数:10,代码来源:CheckoutForm.php

示例12: actionCreate

 /**
  * 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]);
     }
 }
开发者ID:vodas,项目名称:praktykigda,代码行数:17,代码来源:OrderController.php

示例13: createAjax

 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);
     }
 }
开发者ID:vodas,项目名称:praktykirepofinito,代码行数:13,代码来源:OrderController.php

示例14: generateConfig

 /**
  * 依据前台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]]);
 }
开发者ID:whplay,项目名称:ohmate-shop,代码行数:28,代码来源:OrderController.php

示例15: actionIndex

 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'));
 }
开发者ID:diaosj,项目名称:trivial-php-logic,代码行数:50,代码来源:AuctionController.php


注:本文中的app\models\Order::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。