public function destroy($id) { $post = Post::findOrFail($id); priv_check('ForumPostDelete', $post)->ensureCan(); $deletedPostPosition = $post->topic->postPosition($post->post_id); $post->topic->removePost($post, Auth::user()); $topic = Topic::find($post->topic_id); if ($topic === null) { $redirect = route('forum.forums.show', $post->forum); return ujs_redirect($redirect); } return ['postId' => $post->post_id, 'postPosition' => $deletedPostPosition]; }
public function destroy($id) { $post = Post::findOrFail($id); $this->authorizePost($post->forum, $post->topic); if (!$post->canBeDeletedBy(Auth::user())) { abort(403); } $deletedPostPosition = $post->topic->postPosition($post->post_id); $post->topic->removePost($post); $topic = Topic::find($post->topic_id); if ($topic === null) { $redirect = route('forum.forums.show', $post->forum); return ujs_redirect($redirect); } return ['postId' => $post->post_id, 'postPosition' => $deletedPostPosition]; }
public function description() { $topic = Topic::find($this->thread_id); if ($topic === null) { return; } $post = Post::find($topic->topic_first_post_id); // Any description (after the first match) that matches // '[-{15}]' within its body doesn't get split anymore, // and gets stored in $split[1] anyways $split = preg_split('[-{15}]', $post->post_text, 2); // Return empty description if the pattern was not found // (mostly older beatmapsets) $description = $split[1] ?? ''; return (new \App\Libraries\BBCodeFromDB($description, $post->bbcode_uid, true))->toHTML(true); }