public function actionEditPhoto($photo_id) { $model = ClubPhoto::findOne($photo_id); if (Club::isGuest($model->club_id, Yii::$app->user->getId())) { return $this->redirect("/club{$model->club_id}"); } $request = Yii::$app->request; if ($request->isAjax && $model->load($request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->load($request->post()) && $model->validate()) { $model->save(); \Yii::$app->getSession()->setFlash('notify', 'Фотографія успішно редагована!'); return $this->redirect("/club-photo" . $photo_id); } $date = explode(' ', $model->date); $date = explode('-', $date[0]); $photoSrc = '/img/club/photos/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/original_' . $model->src; return $this->render('edit-photo', ['model' => $model, 'photoSrc' => $photoSrc]); }