Exemplo n.º 1
0
 /**
  * Creates a new Orders model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Orders();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
 /**
  * Creates a new Orders model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($amount = 0)
 {
     $model = new Orders();
     if ($model->load(Yii::$app->request->post())) {
         $model->user_id = Yii::$app->user->id;
         if ($amount > 0) {
             $model->order_amount = $amount * 100;
         } else {
             $model->order_amount = $model->order_amount * 100;
             //В базе числа хранятся в целом типе
         }
         $model->save();
         if ($amount > 0) {
             return $this->redirect(['listofgoods/insertall', 'order_id' => $model->order_id]);
         } else {
             return $this->redirect(['view', 'id' => $model->order_id]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'amount' => $amount]);
     }
 }