Skip to content

Commit

Permalink
Merge pull request #15889 from Godmartinz/Fix-user-API-location-update
Browse files Browse the repository at this point in the history
Fixed Users API `update` from clearing `location_id` unnecessarily
  • Loading branch information
snipe authored Nov 26, 2024
2 parents 30b481b + 60642cd commit 37e091a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/Http/Controllers/Api/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,11 @@ public function update(SaveUserRequest $request, User $user): JsonResponse
$user->permissions = $permissions_array;
}

// Update the location of any assets checked out to this user
Asset::where('assigned_type', User::class)
->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]);

if($request->has('location_id')) {
// Update the location of any assets checked out to this user
Asset::where('assigned_type', User::class)
->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]);
}
app('App\Http\Requests\ImageUploadRequest')->handleImages($user, 600, 'image', 'avatars', 'avatar');

if ($user->save()) {
Expand Down

0 comments on commit 37e091a

Please sign in to comment.