From bffed67bf9215b951a3e78142e3f50cfa514676d Mon Sep 17 00:00:00 2001 From: Angel de la Torre Date: Thu, 26 Jun 2025 10:24:11 -0700 Subject: [PATCH] fix(UserController): handle empty assigned_groups input Updated the UserController to ensure that the assigned_groups input defaults to an empty array if not provided. This change prevents potential errors when changing a user's role when said user has still no assigned groups. --- app/Http/Controllers/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index dae33decec..3af2652d23 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -388,7 +388,7 @@ public function postAdminEdit(Request $request): RedirectResponse // The user may have previously been removed from the group, which will mean they have an entry in // users_groups with deleted_at set. Zap that if present so that sync() then works. sync() doesn't // handle soft deletes itself. - $groups = $request->input('assigned_groups'); + $groups = $request->input('assigned_groups', []); foreach ($groups as $idgroups) { $in_group = UserGroups::where('user', $user_id)->where('group', $idgroups)->withTrashed()->first();