Merge pull request #15889 from Godmartinz/Fix-user-API-location-update

Fixed Users API `update` from clearing `location_id` unnecessarily
This commit is contained in:
snipe 2024-11-26 18:45:20 +00:00 committed by GitHub
commit 37e091adbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -480,10 +480,11 @@ class UsersController extends Controller
$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()) {