From 53ac4c9b8f951009957a991efd3270a885931ca8 Mon Sep 17 00:00:00 2001 From: shibafu Date: Mon, 11 Feb 2019 23:25:46 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=8A=E7=9F=A5=E3=82=89=E3=81=9B=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E7=94=BB=E9=9D=A2=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=81=AE?= =?UTF-8?q?=E3=81=BF=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/InfoController.php | 44 ++++++++++++++ resources/views/admin/info/edit.blade.php | 48 ++++++++++++++++ resources/views/admin/info/index.blade.php | 57 +++++++++++++++++++ resources/views/layouts/admin.blade.php | 8 +-- routes/web.php | 4 ++ 5 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 app/Http/Controllers/Admin/InfoController.php create mode 100644 resources/views/admin/info/edit.blade.php create mode 100644 resources/views/admin/info/index.blade.php 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'); });