diff --git a/app/Http/Controllers/Admin/InfoController.php b/app/Http/Controllers/Admin/InfoController.php new file mode 100644 index 0000000..6a1c7c7 --- /dev/null +++ b/app/Http/Controllers/Admin/InfoController.php @@ -0,0 +1,44 @@ +select('id', 'category', 'pinned', 'title', 'created_at') + ->orderByDesc('pinned') + ->orderByDesc('created_at') + ->paginate(20); + + return view('admin.info.index')->with([ + 'informations' => $informations, + 'categories' => Information::CATEGORIES + ]); + } + + public function create() + { + // TODO + } + + public function edit($id) + { + $information = Information::findOrFail($id); + + return view('admin.info.edit')->with([ + 'info' => $information, + 'categories' => Information::CATEGORIES + ]); + } + + public function update(Request $request) + { + // TODO + } +} diff --git a/resources/views/admin/info/edit.blade.php b/resources/views/admin/info/edit.blade.php new file mode 100644 index 0000000..ff3e588 --- /dev/null +++ b/resources/views/admin/info/edit.blade.php @@ -0,0 +1,48 @@ +@extends('layouts.admin') + +@section('title', 'お知らせ') + +@section('tab-content') +
+

お知らせの編集

+
+
+ {{ method_field('PUT') }} + {{ csrf_field() }} + +
+
+ + +
+
+
+ pinned) ? 'checked' : ''}}> + +
+
+
+
+ + +
+
+ + + + 最大 10000 文字、Markdown 形式 + +
+ +
+ + +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/info/index.blade.php b/resources/views/admin/info/index.blade.php new file mode 100644 index 0000000..8d5ae40 --- /dev/null +++ b/resources/views/admin/info/index.blade.php @@ -0,0 +1,57 @@ +@extends('layouts.admin') + +@section('title', 'お知らせ') + +@section('tab-content') +
+

お知らせ

+
+
+ 新規作成 +
+ + + + + + + + + + @foreach($informations as $info) + + + + + + @endforeach + +
カテゴリタイトル作成日
+ @if ($info->pinned) + ピン留め + @endif + {{ $categories[$info->category]['label'] }} + + {{ $info->title }} + + {{ $info->created_at->format('Y年n月j日') }} +
+ +
+@endsection \ No newline at end of file diff --git a/resources/views/layouts/admin.blade.php b/resources/views/layouts/admin.blade.php index d81794c..45fa2b5 100644 --- a/resources/views/layouts/admin.blade.php +++ b/resources/views/layouts/admin.blade.php @@ -4,12 +4,12 @@
-
diff --git a/routes/web.php b/routes/web.php index 121eba5..6f9bfb4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -51,4 +51,8 @@ Route::middleware('can:admin') ->name('admin.') ->group(function () { Route::get('/', 'DashboardController@index')->name('dashboard'); + Route::get('/info', 'InfoController@index')->name('info'); + Route::get('/info/create', 'InfoController@create')->name('info.create'); + Route::get('/info/{id}', 'InfoController@edit')->name('info.edit'); + Route::put('/info/{id}', 'InfoController@update')->name('info.update'); });