/**
  * Creates a new Monitoring2 model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Monitoring2();
     $months = Month::find()->all();
     $years = Year::find()->all();
     $model->user_id = Yii::$app->user->id;
     if ($model->load(Yii::$app->request->post())) {
         $model->date = date('Y-m-d', strtotime($model->date));
         if (!Monitoring2::find()->where(['date' => $model->date, 'user_id' => Yii::$app->user->id])->one()) {
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     }
     return $this->render('create', ['model' => $model, 'months' => $months, 'years' => $years]);
 }