/** * Delete a post * * @param Post $post The post to delete * * @return mixed */ public function deletePost(Post $post) { if ($post['deleted_at'] == null) { // Update counters $post->topic->decrement('num_posts'); $post->topic->forum->decrement('num_posts'); if ($post->user_id > 0) { $post->author->decrement('num_posts'); } // Delete the post $success = $post->delete(); if ($success) { if ($post->topic->last_post_id == $post->id) { $post->topic->update(['last_post_id' => $post->topic->posts->sortByDesc('id')->first()->id]); } if ($post->topic->forum->last_post_id == $post->id) { $this->forumRepository->updateLastPost($post->topic->forum); } } return $success; } else { $this->likesRepository->removeLikesForContent($post); return $post->forceDelete(); } }