Skip to content

Commit

Permalink
fix user api update from clearing location_id unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
Godmartinz committed Nov 26, 2024
1 parent 30b481b commit 60642cd
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 60642cd

Please sign in to comment.