progress
This commit is contained in:
@@ -15,7 +15,12 @@ class ThreadsController extends Controller
|
||||
$category = Category::where('slug', $categorySlug)->first();
|
||||
$thread = Thread::where('slug', $threadSlug)->first();
|
||||
|
||||
$topics = Topic::where('category_id', $category->id)
|
||||
if (!$category || !$thread) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$topics = Topic::with('author')
|
||||
->where('category_id', $category->id)
|
||||
->where('thread_id', $thread->id)
|
||||
->paginate(15);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user