laravel-learn-bbs/app/Http/Controllers/CategoriesController.php

17 lines
438 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\Topic;
use Illuminate\Http\Request;
class CategoriesController extends Controller
{
public function show(Category $category, Request $request)
{
$topics = Topic::where('category_id', $category->id)->withOrder($request->order)->with('user', 'category')->paginate();
return view('topics.index', compact('topics', 'category'));
}
}