|
|
@ -11,7 +11,7 @@ class RoleController extends Controller |
|
|
|
public function add(Request $request) |
|
|
|
public function add(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->validate($request, [ |
|
|
|
$this->validate($request, [ |
|
|
|
'name' => 'required', |
|
|
|
'name' => 'string|required|unique:m_roles,name', |
|
|
|
'description' => 'required' |
|
|
|
'description' => 'required' |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
@ -44,7 +44,12 @@ class RoleController extends Controller |
|
|
|
if(empty($id) || !is_int((int)$id)) |
|
|
|
if(empty($id) || !is_int((int)$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, [ |
|
|
|
|
|
|
|
'name' => 'string|required', |
|
|
|
|
|
|
|
'description' => 'required' |
|
|
|
|
|
|
|
]); |
|
|
|
$data = Role::find($id); |
|
|
|
$data = Role::find($id); |
|
|
|
|
|
|
|
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_roles,name']) : ''; |
|
|
|
|
|
|
|
|
|
|
|
if(!$data) |
|
|
|
if(!$data) |
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404); |
|
|
|
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404); |
|
|
|