/** * Creates a new Catalog model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Catalog(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionCreate() { $model = new Catalog(); $alltable = Catalog::getAllTable(); $request = Yii::$app->request; if ($request->post('Catalog')) { $model->Name = $_POST['Catalog']['Name']; $model->Description = $_POST['Catalog']['Description']; $model->Cost = $_POST['Catalog']['Cost']; $model->Number = $_POST['Catalog']['Number']; $model->save(); return $this->render('index', ['alltable' => $alltable]); } return $this->render('create', ['model' => $model]); }
/** * Creates a new Catalog model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Catalog(); if ($model->load(Yii::$app->request->post()) && $model->save()) { // data catalog $data_catalog = $_POST['Catalog']; // name catalog foreach ($data_catalog as $vlCatalog) { $name_catalog = $vlCatalog; } // last id catalog $last_catalog = Catalog::find()->orderBy('id_catalog DESC')->one(); $last = $last_catalog->id_catalog; // insert search_table $search_catalog = new SearchTable(['name_search' => $name_catalog, 'type_search' => '1', 'link_search' => $last]); $search_catalog->save(); return $this->redirect(['view', 'id' => $model->id_catalog]); } else { return $this->render('create', ['model' => $model]); } }