Ver código fonte

提示友好化

duqinya 5 anos atrás
pai
commit
5fed41246c

+ 0 - 2
app/Http/Controllers/V2/BannerController.php

@@ -61,7 +61,6 @@ class BannerController extends BaseController
     public function bannerSet(Request $request)
     {
         $validator = Validator::make($request->all(), [
-            'name' => 'string|max:20',
             'use_background' => ['required',Rule::in(0,1)],
         ]);
         if ($validator->fails()) {
@@ -77,7 +76,6 @@ class BannerController extends BaseController
     {
         $validator = Validator::make($request->all(), [
             'id' => 'required|exists:config_banner',
-            'name' => 'string|max:20',
         ]);
 
         if ($validator->fails()) {

+ 10 - 0
app/Repositories/BannerRepository.php

@@ -54,6 +54,11 @@ class BannerRepository
             if (!is_int($request['link_content_id'])){
                 throw new HttpException(500, '链接内容必须是数字');
             }
+            $strlen = mb_strlen($request['name'], "utf-8");
+            if ($strlen > 20) {
+                throw new HttpException(500, '名称不能超过20字');
+            }
+
             $banner = [
                 'name' => $request['name'],
                 'link_content_id' => $request['link_content_id'],
@@ -107,6 +112,11 @@ class BannerRepository
             if (!is_int($request['link_content_id'])){
                 throw new HttpException(500, '链接内容必须是数字');
             }
+            $strlen = mb_strlen($request['name'], "utf-8");
+            if ($strlen > 20) {
+                throw new HttpException(500, '名称不能超过20字');
+            }
+
             $banner->name = $request['name'];
             $banner->link_content_id = $request['link_content_id'];
             $banner->image = $request['image'];