This commit is contained in:
2025-08-16 15:38:07 +03:00
parent 11dabec67e
commit d709de39dc
7 changed files with 154 additions and 84 deletions
@@ -16,14 +16,24 @@ class TopicsController extends Controller
public function show(string $categorySlug, string $threadSlug, string $topicSlug)
{
$thread = Thread::with('category')->where('slug', $threadSlug)->first();
$topic = Topic::where('slug', $topicSlug)->first();
$topic = Topic::with('author')->where('slug', $topicSlug)->first();
if (!$topic || !$thread) {
abort(404);
}
$topic->views_no = $topic->views_no+1;
$topic->save();
$posts = Post::with('author')->where('topic_id', $topic->id)->paginate(15);
return view('forum.topics.show', compact('thread', 'topic', 'posts'));
// Get similar topics from the same thread
$similarTopics = Topic::where('thread_id', $thread->id)
->where('id', '!=', $topic->id)
->limit(5)
->get();
return view('forum.topics.show', compact('thread', 'topic', 'posts', 'similarTopics'));
}
public function create(string $categorySlug, string $threadSlug)