mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Update LdapSync.php
Fix for duplicate entries preventing the sync from continuing. SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '13178-6' for key 'PRIMARY' (Connection: mysql, SQL: insert into users_groups (group_id, user_id) values (6, 13178))
This commit is contained in:
parent
93d4d24194
commit
bdb0e6c2a3
|
@ -424,8 +424,12 @@ class LdapSync extends Command
|
||||||
$item['note'] = $item['createorupdate'];
|
$item['note'] = $item['createorupdate'];
|
||||||
$item['status'] = 'success';
|
$item['status'] = 'success';
|
||||||
if ($item['createorupdate'] === 'created' && $ldap_default_group) {
|
if ($item['createorupdate'] === 'created' && $ldap_default_group) {
|
||||||
|
// Check if the relationship already exists
|
||||||
|
if (!$user->groups()->where('group_id', $ldap_default_group)->exists()) {
|
||||||
$user->groups()->attach($ldap_default_group);
|
$user->groups()->attach($ldap_default_group);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//updates assets location based on user's location
|
//updates assets location based on user's location
|
||||||
Asset::where('assigned_to', '=', $user->id)->update(['location_id' => $user->location_id]);
|
Asset::where('assigned_to', '=', $user->id)->update(['location_id' => $user->location_id]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue