Check for no roles being attached #480 (#483)

This commit is contained in:
Nabeel S 2019-12-26 09:42:03 +05:00 committed by GitHub
parent 4f4d0c266a
commit 282cb4be95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -243,9 +243,11 @@ class UserController extends Controller
}
// Delete all of the roles and then re-attach the valid ones
DB::table('role_user')->where('user_id', $id)->delete();
foreach ($request->input('roles') as $key => $value) {
$user->attachRole($value);
if (!empty($request->input('roles'))) {
DB::table('role_user')->where('user_id', $id)->delete();
foreach ($request->input('roles') as $key => $value) {
$user->attachRole($value);
}
}
Flash::success('User updated successfully.');