|
|
|
@ -12,9 +12,9 @@ class MenuController extends Controller
|
|
|
|
|
{ |
|
|
|
|
$this->validate($request, [ |
|
|
|
|
'icon' => 'required', |
|
|
|
|
'name' => 'required', |
|
|
|
|
'url' => 'required', |
|
|
|
|
'sequence' => 'required', |
|
|
|
|
'name' => 'string|required|unique:m_menu,name', |
|
|
|
|
'url' => 'required|unique:m_menu,url', |
|
|
|
|
'sequence' => 'required|integer', |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$data = $request->all(); |
|
|
|
@ -50,9 +50,17 @@ class MenuController extends Controller
|
|
|
|
|
if(!$id || (int) $id < 0 || $id==""){ |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
$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){ |
|
|
|
|
$result = $data->update($request->all()); |
|
|
|
|
}else{ |
|
|
|
|