public function actionChangeName() { $result = []; $this->layout = 'json'; $ref = AlphaId::id(Yii::$app->request->get('ref'), true); $id = AlphaId::id(Yii::$app->request->get('id'), true); $new_name = Yii::$app->request->get('name'); if (!empty($id)) { if (!empty($new_name)) { $user_id = Yii::$app->user->identity->getId(); $model = new PhotobookForm(); if ($model->loadById($id)) { $result = $model->changeName($new_name); } else { $result = ['error' => ['msg' => Yii::t('app', 'Фотокнига не найдена')]]; } } else { $result = ['error' => ['msg' => Yii::t('app', 'Не верно заданные параметры')]]; } } else { $result = ['error' => ['msg' => Yii::t('app', 'Фотокнига не найдена')]]; } return $this->render('json', ['result' => $result]); }