public function actionEdit($id) { if (User::isAdmin(Yii::$app->user->identity->username)) { $value = News::findOne($id); $model = new News(); if (Yii::$app->request->isPost) { $item = Yii::$app->request->post('News'); if (News::updateAll(['title' => $item['title'], 'description' => $item['description'], 'image' => ''], ['id' => $id])) { return $this->redirect('/news/view'); } else { throw new ForbiddenHttpException('Ошибка обновления новости!', 404); } } return $this->render('edit', compact('model', 'value')); } else { throw new ForbiddenHttpException('У вас нет прав администратора!', 404); } }