From 051830dff440625500a2231f05a7fddaf0ac3f30 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Mon, 17 Jul 2023 20:42:02 +0100 Subject: [PATCH] Fix to ldap_location attribute --- app/Console/Commands/LdapSync.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index dd6fea8b66..f77f5f8c48 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -212,9 +212,12 @@ class LdapSync extends Command $item['manager'] = $results[$i][$ldap_result_manager][0] ?? ''; $item['location'] = $results[$i][$ldap_result_location][0] ?? ''; - $location = Location::firstOrCreate([ - 'name' => $item['location'], - ]); + // ONLY if you are using the "ldap_location" option *AND* you have an actual result + if ($ldap_result_location && $item['location']) { + $location = Location::firstOrCreate([ + 'name' => $item['location'], + ]); + } $department = Department::firstOrCreate([ 'name' => $item['department'], ]);