public function actionProfile($id)
 {
     $model = $this->findModel($id);
     if (Yii::$app->user->id === $model->user_id) {
         $model = $this->findModel($id);
         $workModel = OrganizationWork::find()->where(['org_id' => $id])->one();
         if ($workModel === null) {
             $workModel = new OrganizationWork();
         }
         $addressModel = new OrganizationAddress();
         $query = new Query();
         $query->from(OrganizationAddress::tableName());
         $query->where(['org_id' => $id]);
         $addressDataProvider = new ActiveDataProvider(['query' => $query]);
         if ($model->load(Yii::$app->request->post()) && $model->beforeSave() && $model->save()) {
         }
         if ($workModel->load(Yii::$app->request->post()) && $workModel->beforeSave(true) && $workModel->save()) {
         }
         if ($addressModel->load(Yii::$app->request->post()) && ($addressModel->org_id = $model->id) && $addressModel->beforeSave(true) && $addressModel->save()) {
             $addressModel = new OrganizationAddress();
         }
         return $this->render('profile', ['model' => $model, 'workModel' => $workModel, 'addressModel' => $addressModel, 'addressDataProvider' => $addressDataProvider]);
     } else {
         throw new NotFoundHttpException('Access Denied. You need to be owner to perform this operation.');
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrganizationWork()
 {
     return $this->hasOne(OrganizationWork::className(), ['org_id' => 'id']);
 }
 /**
  * Finds the OrganizationWork model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return OrganizationWork the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = OrganizationWork::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }