mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Conditionally update assets when user's location moves via LDAP
This commit is contained in:
parent
c3d52af546
commit
049b9c542b
|
@ -427,7 +427,13 @@ class LdapSync extends Command
|
|||
$user->groups()->attach($ldap_default_group);
|
||||
}
|
||||
//updates assets location based on user's location
|
||||
Asset::where('assigned_to', '=', $user->id)->where('assigned_type', '=', User::class)->update(['location_id' => $user->location_id]);
|
||||
if ($user->wasChanged('location_id')) {
|
||||
foreach ($user->assets as $asset) {
|
||||
$asset->location_id = $user->location_id;
|
||||
// TODO: somehow add note? "Asset Location Changed because of thing"
|
||||
$asset->save();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
foreach ($user->getErrors()->getMessages() as $key => $err) {
|
||||
|
|
Loading…
Reference in a new issue