This commit is contained in:
root 2019-12-12 16:29:35 +08:00
parent 91c4bedbad
commit 21050afa60
2 changed files with 8 additions and 4 deletions

View File

@ -19,7 +19,8 @@ class NoticeController extends Controller
public function save (NoticeSave $request) {
$data = $request->only([
'title',
'content'
'content',
'img_url'
]);
if (!Notice::create($data)) {
abort(500, '保存失败');
@ -32,7 +33,8 @@ class NoticeController extends Controller
public function update (NoticeSave $request) {
$data = $request->only([
'title',
'content'
'content',
'img_url'
]);
if (!Notice::where('id', $request->input('id'))->update($data)) {
abort(500, '保存失败');

View File

@ -15,7 +15,8 @@ class NoticeSave extends FormRequest
{
return [
'title' => 'required',
'content' => 'required'
'content' => 'required',
'img_url' => 'url'
];
}
@ -23,7 +24,8 @@ class NoticeSave extends FormRequest
{
return [
'title.required' => '标题不能为空',
'content.required' => '内容不能为空'
'content.required' => '内容不能为空',
'img_url.url' => '图片URL格式不正确'
];
}
}