/** * Creates a new Product model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { //if(!Yii::$app->user->can('createYourAuth')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth')); $model = new Product(); $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post())) { $model->type = ProductType::arrayToInt($model->type); if ($model->save()) { return $this->redirect(['update', 'id' => $model->id]); } } return $this->render('create', ['model' => $model]); }
/** * Creates a new EntpProduct model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Product(); if ($model->load(Yii::$app->request->post())) { $model->loadDefaultValues(); $model->save(); if ($model->save()) { $produk = new EntpProduct(); $produk->product_id = $this->id; $produk->entrepreneur_user_id = Yii::$app->user->id; $produk->link('product', $model); } Yii::$app->session->setFlash('success', 'Create New Product Success'); return $this->redirect(['index']); //return $this->redirect(['view', 'entrepreneur_id' => $model->entrepreneur_id, 'product_id' => $model->product_id]); } else { return $this->render('create', ['model' => $model]); } }