/** * Creates a new EntpSales model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Sales(); if ($model->load(Yii::$app->request->post())) { $model->loadDefaultValues(); $model->save(); if ($model->save()) { $entp = new EntpSales(); $entp->entrepreneur_user_id = Yii::$app->user->id; $entp->link('sales', $model); } Yii::$app->session->setFlash('success', 'New Sales Added'); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Sales model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $sales = new Sales(); if ($sales->load(Yii::$app->request->post())) { $sales->loadDefaultValues(); $sales->save(); if ($sales->save()) { $entp = new EntpSales(); $entp->sales_id = $this->id; $entp->entrepreneur_id = Yii::$app->user->id; $entp->link('sales', $sales); } Yii::$app->session->setFlash('success', 'New Product Add'); $searchModel = new EntpSalesSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); } else { return $this->render('create', ['model' => $sales]); } }