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

17 lines
438 B
PHP
Raw Normal View History

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