From a78f6178bde74a34b49f3ce47ce0eabffd71c4b2 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 Dec 2019 13:45:46 +0800 Subject: [PATCH] update --- .../Controllers/Admin/NoticeController.php | 28 ++++++++++++++++++ app/Http/Controllers/NoticeController.php | 17 +++++++++++ app/Http/Requests/Admin/NoticeSave.php | 29 +++++++++++++++++++ app/Models/Notice.php | 12 ++++++++ install.sql | 17 ++++++++--- routes/api.php | 5 ++++ update.sql | 10 ++++++- 7 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 app/Http/Controllers/Admin/NoticeController.php create mode 100644 app/Http/Controllers/NoticeController.php create mode 100644 app/Http/Requests/Admin/NoticeSave.php create mode 100644 app/Models/Notice.php diff --git a/app/Http/Controllers/Admin/NoticeController.php b/app/Http/Controllers/Admin/NoticeController.php new file mode 100644 index 00000000..94b52b57 --- /dev/null +++ b/app/Http/Controllers/Admin/NoticeController.php @@ -0,0 +1,28 @@ + Notice::get() + ]); + } + + public function save (NoticeSave $request) { + $data = $request->only([ + 'title', + 'content' + ]); + return response([ + 'data' => Notice::create($data) + ]); + } +} diff --git a/app/Http/Controllers/NoticeController.php b/app/Http/Controllers/NoticeController.php new file mode 100644 index 00000000..7eec0e26 --- /dev/null +++ b/app/Http/Controllers/NoticeController.php @@ -0,0 +1,17 @@ + Notice::orderBy('created_at', 'DESC')->first() + ]); + } +} diff --git a/app/Http/Requests/Admin/NoticeSave.php b/app/Http/Requests/Admin/NoticeSave.php new file mode 100644 index 00000000..694a55ef --- /dev/null +++ b/app/Http/Requests/Admin/NoticeSave.php @@ -0,0 +1,29 @@ + 'required', + 'content' => 'required' + ]; + } + + public function messages() + { + return [ + 'title.required' => '标题不能为空', + 'content.required' => '内容不能为空' + ]; + } +} diff --git a/app/Models/Notice.php b/app/Models/Notice.php new file mode 100644 index 00000000..103642d0 --- /dev/null +++ b/app/Models/Notice.php @@ -0,0 +1,12 @@ +