public function actionFormizin() { if (!yii::$app->user->can('yonetici-form-izin')) { throw new UnauthorizedHttpException(); } $model = new Formizin(); if ($model->load(Yii::$app->request->post())) { $personel = Personel::findOne(['user_id' => yii::$app->user->id]); $model->personel_id = $personel->ID; if ($model->save()) { return $this->redirect(['index']); } } else { return $this->render('create', ['model' => $model]); } }
/** * Finds the Personel model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Personel the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Personel::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }