お知らせ画面の追加
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Ejaculation;
|
||||
use App\Information;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -71,7 +72,14 @@ FROM
|
||||
SQL
|
||||
, ['user_id' => Auth::id()]);
|
||||
|
||||
return view('home')->with(compact('ejaculations', 'currentSession', 'summary'));
|
||||
$informations = Information::query()
|
||||
->select('id', 'category', 'pinned', 'title', 'created_at')
|
||||
->orderBy('pinned')
|
||||
->orderByDesc('created_at')
|
||||
->paginate(3);
|
||||
$categories = Information::CATEGORIES;
|
||||
|
||||
return view('home')->with(compact('ejaculations', 'currentSession', 'summary', 'informations', 'categories'));
|
||||
} else {
|
||||
return view('guest');
|
||||
}
|
||||
|
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
|
||||
]);
|
||||
}
|
||||
}
|
20
app/Information.php
Normal file
20
app/Information.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Information extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
const CATEGORIES = [
|
||||
0 => ['label' => 'お知らせ', 'class' => 'badge-info'],
|
||||
1 => ['label' => 'アップデート', 'class' => 'badge-success'],
|
||||
2 => ['label' => '不具合情報', 'class' => 'badge-danger'],
|
||||
3 => ['label' => 'メンテナンス', 'class' => 'badge-warning']
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
}
|
Reference in New Issue
Block a user