/** * Creates a new FarmerEducation model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($education_id = 0) { $model = new FarmerEducation(); $model->state_id = Yii::$app->user->identity->state_id; $model->year = date('Y'); if (in_array(date('m'), [10, 11, 12])) { $model->quarter = 4; } if (in_array(date('m'), [7, 8, 9])) { $model->quarter = 3; } if (in_array(date('m'), [4, 5, 6])) { $model->quarter = 2; } if (in_array(date('m'), [1, 2, 1])) { $model->quarter = 1; } if ($education_id > 0) { $education = Education::findOne($education_id); $model->education_id = $education_id; } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'education' => $education]); } }