|
|
@@ -74,21 +74,24 @@ class Menu extends Controller
|
|
|
public function store()
|
|
|
{
|
|
|
try {
|
|
|
- $params = request()->all();
|
|
|
-
|
|
|
$validator = [
|
|
|
- 'title' => 'required|string|max:100',
|
|
|
- 'uri' => 'nullable|string|max:255',
|
|
|
- // 'icon' => 'nullable|string',
|
|
|
- // 'permission_name' => 'nullable|string|max:100',
|
|
|
+ 'id' => ['nullable', 'integer'],
|
|
|
'parent_id' => 'nullable|integer',
|
|
|
+ 'title' => 'required|string|max:100',
|
|
|
'status' => 'required|nullable|integer',
|
|
|
- 'type' => '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',
|
|
|
];
|
|
|
|
|
|
- request()->validate($validator);
|
|
|
- unset($params['uri'],$params['type']);
|
|
|
+ $id = request()->input('id');
|
|
|
+ if (!$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) {
|
|
|
return $this->error($ret['code'], $ret['msg']);
|