/** * Delete post by its id * * @param $id * @return bool */ public function deleteById($id) { $post = $this->post->findById($id); if (!$post) { return false; } $this->user->update($post->user, ['posts' => $post->user->posts - 1]); $this->imageUploadService->remove($post->featured); if ($post->type == 'image' || $post->type == 'gif') { $this->imageUploadService->remove($post->thumbnail); $this->imageUploadService->remove($post->media); } $this->post->delete($post); event(new PostWasDeleted($post)); return true; }