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

21 lines
618 B
PHP
Raw Normal View History

2018-01-01 06:51:46 +00:00
<?php
namespace App\Http\Controllers;
use App\Models\Category;
2018-06-02 13:48:16 +00:00
use App\Models\Link;
2018-01-01 06:51:46 +00:00
use App\Models\Topic;
2018-06-02 10:21:53 +00:00
use App\Models\User;
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-06-02 13:48:16 +00:00
public function show(Category $category, Request $request, User $user, Link $link)
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-06-02 13:48:16 +00:00
$links = $link->getAllCached();
2018-06-02 10:21:53 +00:00
$active_users = $user->getActiveUsers();
2018-06-02 13:48:16 +00:00
return view('topics.index', compact('topics', 'category', 'active_users', 'links'));
2018-01-01 06:51:46 +00:00
}
}