/**
  * Creates a new OrganizationWork model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($id)
 {
     $model = new OrganizationWork();
     if ($model->load(Yii::$app->request->post()) && ($model->org_id = $id) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->org_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 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.');
     }
 }