|
|
|
@ -76,21 +76,21 @@ class RoleController extends Controller {
|
|
|
|
|
* @param \App\Models\Role $role
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function update(Request $request, Role $role=null) {
|
|
|
|
|
$data = $request->validate([
|
|
|
|
|
'name' => 'required',
|
|
|
|
|
'slug' => 'required'
|
|
|
|
|
]);
|
|
|
|
|
public function update(Request $request, Role $role = null) {
|
|
|
|
|
|
|
|
|
|
if(!$role){
|
|
|
|
|
if (!$role) {
|
|
|
|
|
return response(['error' => 1, 'message' => 'role doesn\'t exist'], 404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$role->name = $data['name'];
|
|
|
|
|
$role->name = $request->name ?? $role->name;
|
|
|
|
|
|
|
|
|
|
if ($request->slug) {
|
|
|
|
|
if ($role->slug != 'admin' && $role->slug != 'super-admin') {
|
|
|
|
|
//don't allow changing the admin slug, because it will make the routes inaccessbile due to faile ability check
|
|
|
|
|
$role->slug = $data['slug'];
|
|
|
|
|
$role->slug = $request->slug;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$role->update();
|
|
|
|
|
|
|
|
|
|
return $role;
|
|
|
|
|