Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed user assets not updating when a user changes location #14474

Merged
merged 2 commits into from May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/Assets/AssetCheckoutController.php
Expand Up @@ -62,7 +62,7 @@ public function store(AssetCheckoutRequest $request, $assetId)
$this->authorize('checkout', $asset);
$admin = Auth::user();

$target = $this->determineCheckoutTarget($asset);
$target = $this->determineCheckoutTarget();

$asset = $this->updateAssetLocation($asset, $target);

Expand Down
7 changes: 7 additions & 0 deletions app/Http/Controllers/Users/UsersController.php
Expand Up @@ -293,8 +293,15 @@ public function update(SaveUserRequest $request, $id = null)
$user->password = bcrypt($request->input('password'));
}


// 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' => $user->location_id]);

$permissions_array = $request->input('permission');


// Strip out the superuser permission if the user isn't a superadmin
if (! Auth::user()->isSuperUser()) {
unset($permissions_array['superuser']);
Expand Down