authorizeForUser($this->getUser(), 'view', $album); $photo = PhotoController::loadPhotoByAlbumAndFilename($album, $photoFilename); if (!UserConfig::get('allow_photo_comments')) { // Not allowed to post comments - redirect back to URL return redirect($photo->url()); } $comment = new PhotoComment(); $comment->photo_id = $photo->id; $comment->fill($request->only(['commentor_email', 'commentor_name', 'comment_text'])); $user = $this->getUser(); if (!is_null($user) && !$user->isAnonymous()) { $comment->created_user_id = $user->id; } $comment->save(); $request->getSession()->flash('success', trans('gallery.photo_comment_posted_successfully')); return redirect($photo->url()); } }