/**
  * Creates a new Access model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Access();
     $model->user_owner = Yii::$app->user->id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $all_mynotes = Calendar::getDates(Yii::$app->user->id);
         $all_users = User::find()->where('id !=' . Yii::$app->user->id)->asArray()->all();
         //            print_r($all_mynotes);
         //            print_r($all_users);
         //            exit();
         if ($all_mynotes) {
             return $this->render('create', ['model' => $model, 'all_users' => $all_users, 'all_mynotes' => $all_mynotes]);
         } else {
             return $this->redirect('calendar/create');
         }
     }
 }