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


PHP Order::load方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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();
     $modelItems = [new OrderDetail()];
     $customers_model = new Customers();
     $modelUser = new User();
     $model->scenario = 'managerAdd';
     $good_base = $customers_model->find()->where(['isWork' => 1])->orderBy('id')->asArray()->all();
     $customers_base = $arr_keys = $arr_vals = array();
     foreach ($good_base as $key => $value) {
         array_push($arr_keys, $value["id"]);
         array_push($arr_vals, $value["customerName"]);
     }
     $customers_base = array_combine(array($arr_keys), array($arr_vals));
     if ($model->load(Yii::$app->request->post())) {
         $modelItems = OrderDetail::createMultiple(OrderDetail::classname());
         // $modelItems = Model::createMultiple(OrderDetail::classname());
         Model::loadMultiple($modelItems, Yii::$app->request->post());
         // ajax validation
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ArrayHelper::merge(ActiveForm::validateMultiple($modelItems), ActiveForm::validate($model));
         }
         // validate all models
         $valid = $model->validate();
         echo "==model valid  " . $valid . "  <br/>";
         $valid = print_r(Model::validateMultiple($modelItems)) && $valid;
         echo "==model items valid  " . print_r(Model::validateMultiple($modelItems)) . "  <br/>";
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             echo "==(trasaction) start<br/>";
             try {
                 if ($flag = $model->save(false)) {
                     echo "==(trasaction) model saved<br/>";
                     foreach ($modelItems as $modelItem) {
                         echo "==(trasaction) item saved<br/>";
                         $modelItem->orderId = $model->orderId;
                         if (!($flag = $modelItem->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     echo "==(trasaction) commit<br/>";
                     return $this->redirect(['view', 'id' => $model->orderId]);
                     echo "==(trasaction) start redirect<br/>";
                 }
             } catch (Exception $e) {
                 echo "==(trasaction) rollback and exception<br/>";
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('create', ['model' => $model, 'modelItems' => empty($modelItems) ? [new OrderDetail()] : $modelItems, 'customers_base' => $customers_base]);
 }
开发者ID:semvasyl,项目名称:drukarnja_oblik,代码行数:62,代码来源:OrdersController.php

示例5: 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

示例6: 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

示例7: actionCreate

 public function actionCreate()
 {
     $model = new Order();
     if ($model->load(Yii::$app->request->getBodyParams(), '')) {
         $model->file = UploadedFile::getInstance($model, 'file');
         var_dump(Yii::$app->request->getBodyParams());
         Yii::$app->end();
         if ($model->file != null) {
             $model->file->saveAs('img/orders/' . $model->file->name);
             $model->picture = 'img/orders/' . $model->file->name;
         }
         if ($model->save()) {
             return ['success' => true];
         }
     } else {
         return $model;
     }
 }
开发者ID:fosker,项目名称:dbm,代码行数:18,代码来源:OrderController.php

示例8: actionCreate

 /**
  * 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]);
     }
 }
开发者ID:NightWatch-BG,项目名称:sglobka,代码行数:23,代码来源:OrderController.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();
     $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()]);
     }
 }
开发者ID:verget,项目名称:catering,代码行数:27,代码来源:OrderController.php

示例10: actionOrder

 public function actionOrder($id)
 {
     $this->layout = 'page';
     $model = new Order();
     $categories = Category::findAll(['status' => Category::STATUS_ENABLED]);
     $product = Product::find()->where(['id' => $id, 'status' => Product::STATUS_ENABLED])->limit(1)->one();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $order = new Order();
         $order->key = strtoupper(Yii::$app->security->generateRandomString(6));
         $order->name = $product->name;
         $order->thumbnail = $product->thumbnail;
         $order->price = $product->price;
         $order->count = $model->count;
         $order->email = $model->email;
         $order->message = $model->message;
         $order->date = time();
         $order->insert();
         Yii::$app->session->set('orderID', $order->id);
         return $this->redirect(['product/confirm']);
     } else {
         return $this->render('order', ['model' => $model, 'categories' => $categories, 'product' => $product]);
     }
 }
开发者ID:phucnv206,项目名称:thoitrang,代码行数:23,代码来源:ProductController.php

示例11: actionCreateany

 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]);
     }
 }
开发者ID:thehern-troop15,项目名称:pinestraw,代码行数:15,代码来源:OrderController.php

示例12: actionGuestCreate

 public function actionGuestCreate()
 {
     $model = new Order();
     if ($model->load(Yii::$app->request->post())) {
         $model->scenario = 'create';
         $model->create_time = date('Y-m-d H:i:s');
         $model->uid = 0;
         $model->statu = Order::$_AUDIT_PEND;
         $commodityOrderDetail = (new Query())->select('*')->from(CommodityOrder::tableName())->leftJoin(CommodityOrderDetail::tableName(), CommodityOrderDetail::tableName() . '.coid = ' . CommodityOrder::tableName() . '.id')->where('commodity_id = :commodity_id and entrance = :entrance', [':commodity_id' => $model->commodity, ':entrance' => $model->entrance])->one();
         $model->shop = $commodityOrderDetail['shop'];
         $model->fee = $commodityOrderDetail['fee'];
         if ($model->save()) {
             echo "\t<meta charset='utf-8'>";
             echo "<script>alert('提交成功')</script>";
             $model = new Order();
         }
     }
     return $this->render('create', array('model' => $model));
 }
开发者ID:vilison,项目名称:yii2-order,代码行数:19,代码来源:OrderController.php


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