mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
Merge pull request #11154 from inietov/fixes/username_required_on_import
Fixes Username required on import process
This commit is contained in:
commit
4644f1479b
|
@ -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 ItemImporter
|
|||
if ($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) {
|
||||
|
|
Loading…
Reference in a new issue