thread; if(!$this->destroyPostTask->run($request->post)) { return false; } $thread->posts--; /** @var Post $lastPost */ $lastPost = $thread->postings()->latest()->first(); $this->updateThreadTask->run($thread, [ 'posts' => $thread->posts, 'lastpost_uuid' => $lastPost->uuid ?? $thread->firstpost_uuid ]); $this->updateForumTask->run($thread->forum, [ 'lastpost_uuid' => $lastPost->uuid ?? $thread->firstpost_uuid, 'posting_count' => $thread->forum->posting_count - 1 ]); if($thread->posts == 0) { /** @var Thread $latestThread */ $latestThread = $thread->forum->threads()->latest()->first(); $this->updateForumTask->run($thread->forum, [ 'lastpost_uuid' => $latestThread->lastpost_uuid, 'thread_count' => $thread->forum->thread_count - 1 ]); $this->destroyThreadTask->run($thread); } return true; } }