/**
  * Create Profile for user account
  * 
  * @param type $id
  * @return type
  */
 public function actionCreateProfile($id)
 {
     if (\yii::$app->user->can('AdminCreateUserProfile')) {
         $model = new UserProfile();
         $model->id = $id;
         if ($model->load(Yii::$app->request->post())) {
             if ($model->save()) {
                 Yii::$app->getSession()->setFlash('success', 'Profile created !');
                 return $this->redirect(['view', 'id' => $id]);
             } else {
                 Yii::$app->getSession()->setFlash('danger', 'Profile cannot create !');
             }
         } else {
             return $this->render('create-profile', ['profile' => $model]);
         }
     } else {
         throw new \yii\web\NotAcceptableHttpException('No Permission to create user profile');
     }
 }
 /**
  * Creates a new UserProfile model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreateMyProfile()
 {
     $model = $this->findModel(\Yii::$app->user->identity->id);
     if ($model == null) {
         $model = new UserProfile();
         $model->id = \Yii::$app->user->identity->id;
         if ($model->load(Yii::$app->request->post()) && ($user = $model->save())) {
             return $this->redirect(['account/my']);
         } else {
             if (\Yii::$app->request->isAjax) {
                 return $this->renderAjax('create-my-profile', ['model' => $model]);
             } else {
                 return $this->render('create-my-profile', ['model' => $model]);
             }
         }
     } else {
         Yii::$app->getSession()->setFlash('danger', 'profile already created!');
         return $this->actionEditMyProfile();
     }
 }