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 @@ +