Ken 2 settimane fa
parent
commit
13f9477fdb
1 ha cambiato i file con 25 aggiunte e 25 eliminazioni
  1. 25 25
      app/Http/Controllers/admin/Config.php

+ 25 - 25
app/Http/Controllers/admin/Config.php

@@ -21,7 +21,7 @@ class Config extends Controller
     /**
      * @description: 分页数据
      * @return {*}
-     */    
+     */
     function index()
     {
         try {
@@ -42,35 +42,35 @@ class Config extends Controller
     /**
      * @description: 修改|新增
      * @return {*}
-     */    
+     */
     public function store()
     {
         // try {
-            $params = request()->all();
-
-            $id = request()->post('id','');
-            if($id){
-                $validator = [
-                    'field' => 'required|string|max:50|alpha_dash|unique:config,field,'.$id,
-                    'val' => 'nullable|string',
-                    'remark' => 'required|nullable|string',
-                ];
-            }else{
-                $validator = [
-                    'field' => 'required|string|max:50|alpha_dash|unique:config,field',
-                    'val' => 'nullable|string',
-                    'remark' => 'required|nullable|string',
-                ];
-            }
+        $params = request()->all();
+
+        $id = request()->post('id', '');
+        if ($id) {
+            $validator = [
+                'field' => 'required|string|max:50|alpha_dash|unique:config,field,' . $id,
+                'val' => 'nullable|string',
+                'remark' => 'required|nullable|string',
+            ];
+        } else {
+            $validator = [
+                'field' => 'required|string|max:50|alpha_dash|unique:config,field',
+                'val' => 'nullable|string',
+                'remark' => 'required|nullable|string',
+            ];
+        }
 // 
-            
 
-            request()->validate($validator);
 
-            $ret = ConfigService::submit($params);
-            if ($ret['code'] == ConfigService::NOT) {
-                return $this->error($ret['code'], $ret['msg']);
-            }
+        request()->validate($validator);
+        unset($params['field']);
+        $ret = ConfigService::submit($params);
+        if ($ret['code'] == ConfigService::NOT) {
+            return $this->error($ret['code'], $ret['msg']);
+        }
         // } catch (ValidationException $e) {
         //     return $this->error(HttpStatus::VALIDATION_FAILED, '', $e->errors());
         // } catch (Exception $e) {
@@ -273,7 +273,7 @@ class Config extends Controller
             } else {
                 request()->validate([
                     'chatId' => ['required', 'string', 'min:1'],
-                    'video' => ['required','url'],
+                    'video' => ['required', 'url'],
                     'video_caption' => ['nullable', 'string'],
                     'isSend' => ['nullable', 'boolean'],
                     'isTop' => ['nullable', 'boolean'],