Ken 2 minggu lalu
induk
melakukan
e01313bf26
1 mengubah file dengan 4 tambahan dan 7 penghapusan
  1. 4 7
      app/Http/Controllers/admin/Menu.php

+ 4 - 7
app/Http/Controllers/admin/Menu.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\admin;
 
 use App\Constants\HttpStatus;
 use App\Http\Controllers\Controller;
+use App\Services\BaseService;
 use App\Services\MenuService;
 use Exception;
 
@@ -74,6 +75,7 @@ class Menu extends Controller
     public function store()
     {
         try {
+            $id = request()->input('id');
             $validator = [
                 'id' => ['nullable', 'integer'],
                 'parent_id' => 'nullable|integer',
@@ -81,19 +83,14 @@ class Menu extends Controller
                 'status' => 'required|nullable|integer',
                 'icon' => 'nullable|string',
                 'sort' => 'required|nullable|integer',
-//                'uri' => 'nullable|string|max:255',
-                // 'permission_name'  => 'nullable|string|max:100',
-//                'type' => 'required|nullable|integer',
             ];
-
-            $id = request()->input('id');
-            if (!$id) {
+            if (empty($id)) {
                 $validator['uri'] = ['required', 'string', 'max:200'];
                 $validator['type'] = ['required', 'integer', 'in:1,2'];
             }
             $params = request()->validate($validator);
             $ret = MenuService::submit($params);
-            if ($ret['code'] == MenuService::NOT) {
+            if ($ret['code'] == BaseService::NOT) {
                 return $this->error($ret['code'], $ret['msg']);
             }
         } catch (ValidationException $e) {