お知らせ画面の追加
This commit is contained in:
34
app/Http/Controllers/InfoController.php
Normal file
34
app/Http/Controllers/InfoController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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')
|
||||
->orderBy('pinned')
|
||||
->orderByDesc('created_at')
|
||||
->paginate(20);
|
||||
return view('info.index')->with([
|
||||
'informations' => $informations,
|
||||
'categories' => Information::CATEGORIES
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$information = Information::findOrFail($id);
|
||||
$parser = new \Parsedown();
|
||||
$compiledContent = $parser->text($information->content);
|
||||
return view('info.show')->with([
|
||||
'info' => $information,
|
||||
'category' => Information::CATEGORIES[$information->category],
|
||||
'compiledContent' => $compiledContent
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user