|
|
@ -12,9 +12,9 @@ class MenuController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->validate($request, [ |
|
|
|
$this->validate($request, [ |
|
|
|
'icon' => 'required', |
|
|
|
'icon' => 'required', |
|
|
|
'name' => 'required', |
|
|
|
'name' => 'string|required|unique:m_menu,name', |
|
|
|
'url' => 'required', |
|
|
|
'url' => 'required|unique:m_menu,url', |
|
|
|
'sequence' => 'required', |
|
|
|
'sequence' => 'required|integer', |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
$data = $request->all(); |
|
|
|
$data = $request->all(); |
|
|
@ -50,9 +50,17 @@ class MenuController extends Controller |
|
|
|
if(!$id || (int) $id < 0 || $id==""){ |
|
|
|
if(!$id || (int) $id < 0 || $id==""){ |
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$this->validate($request, [ |
|
|
|
|
|
|
|
'icon' => 'required', |
|
|
|
|
|
|
|
'name' => 'string|required', |
|
|
|
|
|
|
|
'url' => 'required', |
|
|
|
|
|
|
|
'sequence' => 'required|integer', |
|
|
|
|
|
|
|
]); |
|
|
|
$data = Menu::find($id); |
|
|
|
$data = Menu::find($id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_menu,name']) : ''; |
|
|
|
|
|
|
|
$request->url !== $data['url'] ? $this->validate($request,['url'=>'unique:m_menu,url']) : ''; |
|
|
|
|
|
|
|
|
|
|
|
if($data){ |
|
|
|
if($data){ |
|
|
|
$result = $data->update($request->all()); |
|
|
|
$result = $data->update($request->all()); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|