2017-11-03 20:38:09 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Information;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class InfoController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$informations = Information::query()
|
|
|
|
->select('id', 'category', 'pinned', 'title', 'created_at')
|
2017-11-07 00:57:33 +09:00
|
|
|
->orderByDesc('pinned')
|
2017-11-03 20:38:09 +09:00
|
|
|
->orderByDesc('created_at')
|
|
|
|
->paginate(20);
|
2019-01-15 00:05:01 +09:00
|
|
|
|
2017-11-03 20:38:09 +09:00
|
|
|
return view('info.index')->with([
|
|
|
|
'informations' => $informations,
|
|
|
|
'categories' => Information::CATEGORIES
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function show($id)
|
|
|
|
{
|
|
|
|
$information = Information::findOrFail($id);
|
2019-01-15 00:05:01 +09:00
|
|
|
|
2017-11-03 20:38:09 +09:00
|
|
|
return view('info.show')->with([
|
|
|
|
'info' => $information,
|
2017-11-03 23:23:36 +09:00
|
|
|
'category' => Information::CATEGORIES[$information->category]
|
2017-11-03 20:38:09 +09:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|