/** * Creates a new Employees model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Employees(); if ($model->load(Yii::$app->request->post())) { $model->employee_status = 'Y'; if ($model->save()) { Yii::$app->session->setFlash('success', 'Karyawan berhasil disimpan'); } return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Employees model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Employees(); if ($model->load(Yii::$app->request->post())) { $file = UploadedFile::getInstance($model, 'avatar_img'); if ($file->size != 0) { $model->avatar = $file->name; $file->saveAs('avatars/' . $file->name); $model->save(); } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }