Ejemplo n.º 1
0
 public function actionAdd()
 {
     $session = Yii::$app->session;
     $session->open();
     $consumer = Consumers::find()->where(['user_id' => Yii::$app->user->id])->one();
     $order = new Orders();
     if (!empty($consumer) && $order->load(Yii::$app->request->post())) {
         $order->consumer_id = $consumer->id;
         $order->order_status_id = 1;
         $order->qty = $session['cart.qty'];
         $order->sum = $session['cart.sum'];
         if ($order->save()) {
             $this->saveOrdersItem($session['cart'], $order->id);
             Yii::$app->session->setFlash('success', 'Заказ принят!');
             $session->remove('cart');
             $session->remove('cart.qty');
             $session->remove('cart.sum');
         }
     }
     return $this->redirect('/my-dashboard/orders');
 }
Ejemplo n.º 2
0
 public function actionProfile()
 {
     $model = Consumers::find()->select('consumers.*')->where(['consumers.user_id' => Yii::$app->user->id])->one();
     $queryActive = Orders::find()->select('orders.*')->leftJoin('orders_status', 'orders.order_status_id = orders_status.id')->leftJoin('consumers', 'orders.consumer_id = consumers.id')->leftJoin('user', 'consumers.user_id = user.id')->where(['user.id' => Yii::$app->user->id])->where(['orders.order_status_id' => 1]);
     $ordersCount = $queryActive->count();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $model->save();
             Yii::$app->session->setFlash('success', 'Данные успешно изменены!');
         } else {
             Yii::$app->session->setFlash('danger', 'Данные не были сохранены!');
         }
     }
     return $this->render('view', ['model' => $model, 'ordersCount' => $ordersCount, 'actionType' => 'profile']);
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrders()
 {
     return $this->hasMany(Orders::className(), ['consumer_id' => 'id']);
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrders()
 {
     return $this->hasMany(Orders::className(), ['objreservation_id' => 'id']);
 }
Ejemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrders()
 {
     return $this->hasMany(Orders::className(), ['order_status_id' => 'id']);
 }