/**
  * Creates a new Products model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Products();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemple #2
0
 /**
  * Creates a new Products model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Products();
     if ($model->load(Yii::$app->request->post())) {
         date_default_timezone_set('Asia/Calcutta');
         $model->createdDate = date("Y-m-d H:i:s");
         $model->updatedDate = date("Y-m-d H:i:s");
         $model->save();
         Yii::$app->session->setFlash('success', "Product successfully Created");
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }