refactor: 文章分类新增/更新添加图片及唯一标识
This commit is contained in:
@@ -76,13 +76,18 @@ class ArticleCategory
|
||||
public function save()
|
||||
{
|
||||
$post = request()->post([
|
||||
'unique_label',
|
||||
'name',
|
||||
'icon',
|
||||
'pid',
|
||||
'sort' => 0,
|
||||
'is_show' => 1
|
||||
]);
|
||||
|
||||
$data = array_merge($post, ['language_id' => request()->lang_id]);
|
||||
$data = array_merge($post, [
|
||||
'language_id' => request()->lang_id,
|
||||
'unique_label' => $post['unique_label'] ?? uniqid('BANNER_')
|
||||
]);
|
||||
$valiate = new ArticleCategoryValidate;
|
||||
if (!$valiate->scene('add')->check($data)) {
|
||||
return error($valiate->getError());
|
||||
@@ -101,6 +106,7 @@ class ArticleCategory
|
||||
$id = request()->param('id');
|
||||
$put = request()->put([
|
||||
'name',
|
||||
'icon',
|
||||
'pid',
|
||||
'sort',
|
||||
'is_show'
|
||||
@@ -108,7 +114,7 @@ class ArticleCategory
|
||||
$data = array_merge($put, ['language_id' => request()->lang_id]);
|
||||
|
||||
$valiate = new ArticleCategoryValidate;
|
||||
if (!$valiate->check(array_merge($data, ['id' => $id]))) {
|
||||
if (!$valiate->scene('edit')->check(array_merge($data, ['id' => $id]))) {
|
||||
return error($valiate->getError());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user