App\Http\Controllers\Forum\PostsController::destroy PHP Method

destroy() public method

public destroy ( $id )
    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];
    }