update: add notice tags

This commit is contained in:
tokumeikoi 2022-04-15 02:45:52 +08:00
parent 0bcaf2889a
commit d20dce7f69
6 changed files with 14 additions and 6 deletions

View File

@ -22,7 +22,8 @@ class NoticeController extends Controller
$data = $request->only([
'title',
'content',
'img_url'
'img_url',
'tags'
]);
if (!$request->input('id')) {
if (!Notice::create($data)) {

View File

@ -16,7 +16,8 @@ class NoticeSave extends FormRequest
return [
'title' => 'required',
'content' => 'required',
'img_url' => 'nullable|url'
'img_url' => 'nullable|url',
'tags' => 'nullable|array'
];
}
@ -25,7 +26,8 @@ class NoticeSave extends FormRequest
return [
'title.required' => '标题不能为空',
'content.required' => '内容不能为空',
'img_url.url' => '图片URL格式不正确'
'img_url.url' => '图片URL格式不正确',
'tags.array' => '标签格式不正确'
];
}
}

View File

@ -11,6 +11,7 @@ class Notice extends Model
protected $guarded = ['id'];
protected $casts = [
'created_at' => 'timestamp',
'updated_at' => 'timestamp'
'updated_at' => 'timestamp',
'tags' => 'array'
];
}

View File

@ -101,6 +101,7 @@ CREATE TABLE `v2_notice` (
`content` text NOT NULL,
`show` tinyint(1) NOT NULL DEFAULT '0',
`img_url` varchar(255) DEFAULT NULL,
`tags` varchar(255) DEFAULT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
PRIMARY KEY (`id`)
@ -376,4 +377,4 @@ CREATE TABLE `v2_user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2022-03-29 06:56:01
-- 2022-04-14 18:42:31

View File

@ -557,3 +557,6 @@ ALTER TABLE `v2_stat_user`
DROP `server_id`;
ALTER TABLE `v2_stat_user`
DROP `server_type`;
ALTER TABLE `v2_notice`
ADD `tags` varchar(255) COLLATE 'utf8_general_ci' NULL AFTER `img_url`;

File diff suppressed because one or more lines are too long