/** * Creates a new Departments model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Departments(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public static function addDepartments($input) { foreach ($input as $value) { if ($value != null) { $departments = new Departments(); $departments->name = $value; $departments->condition = 1; $departments->save(); } } }
/** * Creates a new Departments model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Departments(); if ($model->load(Yii::$app->request->post())) { $model->department_created_date = date('Y-m-d'); $model->save(); return $this->redirect(['view', 'id' => $model->department_id]); } else { return $this->renderAjax('create', ['model' => $model]); } }