A free open source IT asset/license management system
Call User::generateFormattedNameFromFullName() in the UserImporter
Ivan Nieto Vivanco32111a863b3b
diff --git a/app/Importer/UserImporter.php b/app/Importer/UserImporter.phpindex 940c758f34..3177cee20e 100644--- a/app/Importer/UserImporter.php+++ b/app/Importer/UserImporter.php@@ -3,6 +3,7 @@namespace App\Importer;use App\Models\Department;+use App\Models\Setting;use App\Models\User;use App\Notifications\WelcomeNotification;@@ -60,6 +61,13 @@ class UserImporter extends ItemImporterif ($this->shouldUpdateField($user_department)) {$this->item['department_id'] = $this->createOrFetchDepartment($user_department);}++ if (is_null($this->item['username']) || $this->item['username'] == "") {+ $user_full_name = $this->item['first_name'] . ' ' . $this->item['last_name'];+ $user_formatted_array = User::generateFormattedNameFromFullName($user_full_name, Setting::getSettings()->username_format);+ $this->item['username'] = $user_formatted_array['username'];+ }+$user = User::where('username', $this->item['username'])->first();if ($user) {if (! $this->updating) {