mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-23 11:43:47 -08:00
Fixed #5150 - added lastname first initial as username format
This commit is contained in:
parent
a5c6ddb8ac
commit
d05dfb18a7
|
@ -346,7 +346,10 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
|||
$username = str_slug(substr($first_name, 0, 1).$last_name);
|
||||
|
||||
if ($format=='firstname.lastname') {
|
||||
$username = str_slug($first_name).'.'.str_slug($last_name);
|
||||
$username = str_slug($first_name) . '.' . str_slug($last_name);
|
||||
|
||||
} elseif ($format=='lastnamefirstinitial') {
|
||||
$username = str_slug($last_name.substr($first_name, 0, 1));
|
||||
|
||||
} elseif ($format=='firstname_lastname') {
|
||||
$username = str_slug($first_name).'_'.str_slug($last_name);
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
'filastname_format' => 'First Initial Last Name (jsmith@example.com)',
|
||||
'firstname_lastname_format' => 'First Name Last Name (jane.smith@example.com)',
|
||||
'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)',
|
||||
'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)',
|
||||
'first' => 'First',
|
||||
'first_name' => 'First Name',
|
||||
'first_name_format' => 'First Name (jane@example.com)',
|
||||
|
|
|
@ -456,6 +456,7 @@ Form::macro('username_format', function ($name = "username_format", $selected =
|
|||
'firstname.lastname' => trans('general.firstname_lastname_format'),
|
||||
'firstname' => trans('general.first_name_format'),
|
||||
'filastname' => trans('general.filastname_format'),
|
||||
'lastnamefirstinitial' => trans('general.lastnamefirstinitial_format'),
|
||||
'firstname_lastname' => trans('general.firstname_lastname_underscore_format'),
|
||||
|
||||
);
|
||||
|
|
|
@ -54,6 +54,14 @@ class UserTest extends BaseTest
|
|||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
|
||||
public function testLastNameFirstInitial()
|
||||
{
|
||||
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
|
||||
$expected_username = 'allanovna-romanova-oshostakovan';
|
||||
$user = User::generateFormattedNameFromFullName('lastnamefirstinitial', $fullname);
|
||||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
|
||||
|
||||
public function testFirstInitialLastName()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue