${html(user.email)}
diff --git a/public/assets/user/read/user-read-update-main.js b/public/assets/user/read/user-read-update-main.js
index 27d212ff..e33ecdef 100644
--- a/public/assets/user/read/user-read-update-main.js
+++ b/public/assets/user/read/user-read-update-main.js
@@ -18,7 +18,7 @@ loadUserActivities(`user=${userId}`);
document.querySelector('#edit-first-name-btn')?.addEventListener('click', makeUserFieldEditable);
document.querySelector('h1[data-name="first_name"]')?.addEventListener('dblclick', makeUserFieldEditable);
document.querySelector('#edit-last-name-btn')?.addEventListener('click', makeUserFieldEditable);
-document.querySelector('h1[data-name="surname"]')?.addEventListener('dblclick', makeUserFieldEditable);
+document.querySelector('h1[data-name="last_name"]')?.addEventListener('dblclick', makeUserFieldEditable);
document.querySelector('#edit-email-btn')?.addEventListener('click', makeUserFieldEditable);
document.querySelector('[data-name="email"]')?.addEventListener('dblclick', makeUserFieldEditable);
diff --git a/resources/migrations/20240425150810_db_change_1527712828662a_71da_9af_9f.php b/resources/migrations/20240425150810_db_change_1527712828662a_71da_9af_9f.php
index d26a0f3e..ff9c098f 100644
--- a/resources/migrations/20240425150810_db_change_1527712828662a_71da_9af_9f.php
+++ b/resources/migrations/20240425150810_db_change_1527712828662a_71da_9af_9f.php
@@ -422,7 +422,7 @@ public function change()
'encoding' => 'utf8mb4',
'after' => 'id',
])
- ->addColumn('surname', 'string', [
+ ->addColumn('last_name', 'string', [
'null' => true,
'default' => null,
'limit' => 100,
@@ -434,7 +434,7 @@ public function change()
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
- 'after' => 'surname',
+ 'after' => 'last_name',
])
->addColumn('status', 'enum', [
'null' => true,
diff --git a/resources/schema/schema.php b/resources/schema/schema.php
index 3510c66e..08d3d362 100644
--- a/resources/schema/schema.php
+++ b/resources/schema/schema.php
@@ -1751,11 +1751,11 @@
'IS_GENERATED' => 'NEVER',
'GENERATION_EXPRESSION' => NULL,
),
- 'surname' =>
+ 'last_name' =>
array (
'TABLE_CATALOG' => 'def',
'TABLE_NAME' => 'user',
- 'COLUMN_NAME' => 'surname',
+ 'COLUMN_NAME' => 'last_name',
'ORDINAL_POSITION' => 3,
'COLUMN_DEFAULT' => 'NULL',
'IS_NULLABLE' => 'YES',
diff --git a/resources/schema/schema.sql b/resources/schema/schema.sql
index 1def218a..9fad66d6 100644
--- a/resources/schema/schema.sql
+++ b/resources/schema/schema.sql
@@ -7,7 +7,7 @@ CREATE TABLE `authentication_log` (
`created_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `authentication_log_user_id_fk` (`user_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE `client` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@@ -29,14 +29,14 @@ CREATE TABLE `client` (
PRIMARY KEY (`id`),
KEY `FK_client_user` (`user_id`),
KEY `FK_client_status` (`client_status_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Advisors help and consult clients';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Advisors help and consult clients';
CREATE TABLE `client_status` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '0',
`deleted_at` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Client status';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Client status';
CREATE TABLE `email_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@@ -48,7 +48,7 @@ CREATE TABLE `email_log` (
`created_at` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `email_log_user_id_fk` (`user_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE `note` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@@ -63,7 +63,7 @@ CREATE TABLE `note` (
PRIMARY KEY (`id`),
KEY `FK__user` (`user_id`),
KEY `FK_note_client` (`client_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE `phinx_migration_log` (
`version` bigint(20) NOT NULL,
@@ -77,7 +77,7 @@ CREATE TABLE `phinx_migration_log` (
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) DEFAULT NULL,
- `surname` varchar(100) DEFAULT NULL,
+ `last_name` varchar(100) DEFAULT NULL,
`user_role_id` int(11) NOT NULL DEFAULT 0,
`status` enum('active','locked','unverified','suspended') DEFAULT 'unverified',
`email` varchar(254) NOT NULL,
@@ -89,7 +89,7 @@ CREATE TABLE `user` (
`deleted_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_user_user_role` (`user_role_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE `user_activity` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@@ -103,7 +103,7 @@ CREATE TABLE `user_activity` (
`user_agent` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_activity_user_id_fk` (`user_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE `user_filter_setting` (
`user_id` int(11) NOT NULL,
@@ -117,7 +117,7 @@ CREATE TABLE `user_role` (
`name` varchar(30) NOT NULL,
`hierarchy` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE `user_verification` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@@ -129,4 +129,4 @@ CREATE TABLE `user_verification` (
`deleted_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK__user_table` (`user_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
\ No newline at end of file
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
\ No newline at end of file
diff --git a/resources/seeds/AdminUserSeeder.php b/resources/seeds/AdminUserSeeder.php
index b6a140f9..63b011eb 100644
--- a/resources/seeds/AdminUserSeeder.php
+++ b/resources/seeds/AdminUserSeeder.php
@@ -32,7 +32,7 @@ public function run(): void
$userRows = [
[
'first_name' => 'Admin',
- 'surname' => 'Admin',
+ 'last_name' => 'Admin',
'user_role_id' => 1,
'status' => 'active',
'email' => 'admin@user.com',
diff --git a/resources/seeds/UserSeeder.php b/resources/seeds/UserSeeder.php
index 0deaf1df..4a7242c6 100644
--- a/resources/seeds/UserSeeder.php
+++ b/resources/seeds/UserSeeder.php
@@ -34,7 +34,7 @@ public function run(): void
[
'id' => 2,
'first_name' => 'Managing-advisor',
- 'surname' => 'Surname',
+ 'last_name' => 'Last name',
'user_role_id' => 2,
'status' => 'active',
'language' => 'en_US',
@@ -44,7 +44,7 @@ public function run(): void
[
'id' => 3,
'first_name' => 'Advisor',
- 'surname' => 'Surname',
+ 'last_name' => 'Surname',
'user_role_id' => 3,
'status' => 'active',
'language' => 'de_CH',
@@ -54,7 +54,7 @@ public function run(): void
[
'id' => 4,
'first_name' => 'Newcomer',
- 'surname' => 'Surname',
+ 'last_name' => 'Surname',
'user_role_id' => 4,
'status' => 'active',
'language' => 'fr_CH',
diff --git a/src/Domain/Client/Repository/ClientFinderRepository.php b/src/Domain/Client/Repository/ClientFinderRepository.php
index f9133c2e..f1c279b9 100644
--- a/src/Domain/Client/Repository/ClientFinderRepository.php
+++ b/src/Domain/Client/Repository/ClientFinderRepository.php
@@ -45,7 +45,7 @@ public function findClientsWithResultAggregate(array $whereArray = ['client.dele
'deleted_at' => 'client.deleted_at',
// User data prefixed with user_
'user_first_name' => 'user.first_name',
- 'user_surname' => 'user.surname',
+ 'user_last_name' => 'user.last_name',
// Client status data prefixed with client_status_
'client_status_name' => 'client_status.name',
])// Multiple joins doc: https://book.cakephp.org/4/en/orm/query-builder.html#adding-joins
@@ -116,7 +116,7 @@ public function findClientAggregateByIdIncludingDeleted(int $id): ClientReadResu
'deleted_at' => 'client.deleted_at',
// User data prefixed with user_
'user_first_name' => 'user.first_name',
- 'user_surname' => 'user.surname',
+ 'user_last_name' => 'user.last_name',
// Client status data prefixed with client_status_
'client_status_name' => 'client_status.name',
// Main note data loaded in page renderer prefixed with `note_`
diff --git a/src/Domain/Note/Repository/NoteFinderRepository.php b/src/Domain/Note/Repository/NoteFinderRepository.php
index 3d8dbd6e..6426554d 100644
--- a/src/Domain/Note/Repository/NoteFinderRepository.php
+++ b/src/Domain/Note/Repository/NoteFinderRepository.php
@@ -56,7 +56,7 @@ public function findAllNotesExceptMainByUserId(int $userId): array
{
$query = $this->queryFactory->selectQuery()->from('note');
- $concatName = $query->func()->concat(['user.first_name' => 'identifier', ' ', 'user.surname' => 'identifier']);
+ $concatName = $query->func()->concat(['user.first_name' => 'identifier', ' ', 'user.last_name' => 'identifier']);
$query->select(array_merge($this->noteResultFields, ['user_full_name' => $concatName]))
->join(['table' => 'user', 'conditions' => 'note.user_id = user.id'])
@@ -87,7 +87,7 @@ public function findAllNotesExceptMainWithUserByClientId(int $clientId): array
$concatName = $query->func()->concat([
$query->func()->coalesce(['user.first_name' => 'identifier', '']),
' ',
- $query->func()->coalesce(['user.surname' => 'identifier', '']),
+ $query->func()->coalesce(['user.last_name' => 'identifier', '']),
]);
$query->select(array_merge($this->noteResultFields, ['user_full_name' => $concatName]))
@@ -123,7 +123,7 @@ public function findMostRecentNotes(int $notesAmount): array
$concatUserName = $query->func()->concat(
// Not very sexy to put IFNULL function there but with "identifier", cake interprets the string literally
- ['IFNULL(user.first_name, "")' => 'identifier', ' ', 'IFNULL(user.surname, "")' => 'identifier']
+ ['IFNULL(user.first_name, "")' => 'identifier', ' ', 'IFNULL(user.last_name, "")' => 'identifier']
);
$concatClientName = $query->func()->concat(
['IFNULL(client.first_name, "")' => 'identifier', ' ', 'IFNULL(client.last_name, "")' => 'identifier']
diff --git a/src/Domain/Note/Service/NoteCreator.php b/src/Domain/Note/Service/NoteCreator.php
index 4e3bf2c7..a1749ab6 100644
--- a/src/Domain/Note/Service/NoteCreator.php
+++ b/src/Domain/Note/Service/NoteCreator.php
@@ -59,7 +59,7 @@ public function createNote(array $noteValues): array
return [
'note_id' => $noteId,
- 'user_full_name' => $user->firstName . ' ' . $user->surname,
+ 'user_full_name' => $user->firstName . ' ' . $user->lastName,
'formatted_creation_timestamp' => $dateFormatter->format($noteCreatedAtTimestamp),
];
}
diff --git a/src/Domain/User/Data/UserData.php b/src/Domain/User/Data/UserData.php
index fa7feaa8..1c132974 100644
--- a/src/Domain/User/Data/UserData.php
+++ b/src/Domain/User/Data/UserData.php
@@ -11,7 +11,7 @@ class UserData implements \JsonSerializable
// Variable names matching database columns (camelCase instead of snake_case)
public ?int $id; // Mysql always returns string from db https://stackoverflow.com/a/5323169/9013718
public ?string $firstName;
- public ?string $surname;
+ public ?string $lastName;
// Email has to be default null as it is an indicator that user obj is empty in AuthService register function
public ?string $email;
public ?string $password;
@@ -30,7 +30,7 @@ public function __construct(array $userData = [])
// Keys may be taken from view form or database, so they have to correspond to both; otherwise use mapper
$this->id = $userData['id'] ?? null;
$this->firstName = $userData['first_name'] ?? null;
- $this->surname = $userData['surname'] ?? null;
+ $this->lastName = $userData['last_name'] ?? null;
$this->email = $userData['email'] ?? null;
$this->password = $userData['password'] ?? null;
$this->password2 = $userData['password2'] ?? null;
@@ -47,13 +47,13 @@ public function __construct(array $userData = [])
}
/**
- * Returns the first and surname in one string separated by a whitespace.
+ * Returns the first and lastName in one string separated by a whitespace.
*
* @return string
*/
public function getFullName(): string
{
- return $this->firstName . ' ' . $this->surname;
+ return $this->firstName . ' ' . $this->lastName;
}
/**
@@ -68,7 +68,7 @@ public function toArrayForDatabase(): array
return [
'id' => $this->id,
'first_name' => $this->firstName,
- 'surname' => $this->surname,
+ 'last_name' => $this->lastName,
'email' => $this->email,
'password_hash' => $this->passwordHash,
'user_role_id' => $this->userRoleId,
@@ -83,7 +83,7 @@ public function jsonSerialize(): array
return [
'id' => $this->id,
'firstName' => $this->firstName,
- 'surname' => $this->surname,
+ 'lastName' => $this->lastName,
'email' => $this->email,
'status' => $this->status,
'userRoleId' => $this->userRoleId,
diff --git a/src/Domain/User/Repository/UserFinderRepository.php b/src/Domain/User/Repository/UserFinderRepository.php
index 82c2b7bc..06ffbd90 100644
--- a/src/Domain/User/Repository/UserFinderRepository.php
+++ b/src/Domain/User/Repository/UserFinderRepository.php
@@ -13,7 +13,7 @@ class UserFinderRepository
private array $fields = [
'id',
'first_name',
- 'surname',
+ 'last_name',
'email',
'user_role_id',
'status',
diff --git a/src/Domain/User/Service/Authorization/UserPermissionVerifier.php b/src/Domain/User/Service/Authorization/UserPermissionVerifier.php
index 25815ca2..19342bf1 100644
--- a/src/Domain/User/Service/Authorization/UserPermissionVerifier.php
+++ b/src/Domain/User/Service/Authorization/UserPermissionVerifier.php
@@ -185,7 +185,7 @@ public function isGrantedToUpdate(array $userDataToUpdate, string|int $userIdToU
// Personal info are values such as first name, last name and email
$grantedUpdateKeys[] = 'personal_info';
$grantedUpdateKeys[] = 'first_name';
- $grantedUpdateKeys[] = 'surname';
+ $grantedUpdateKeys[] = 'last_name';
$grantedUpdateKeys[] = 'email';
$grantedUpdateKeys[] = 'password_hash';
$grantedUpdateKeys[] = 'theme';
diff --git a/src/Domain/User/Service/UserNameAbbreviator.php b/src/Domain/User/Service/UserNameAbbreviator.php
index 9d7c2166..f6210ffc 100644
--- a/src/Domain/User/Service/UserNameAbbreviator.php
+++ b/src/Domain/User/Service/UserNameAbbreviator.php
@@ -28,7 +28,7 @@ private function buildLastNameAbbreviation(string $lastName, array $usersToCheck
): string {
// When $i (amount of letters) of last name to abbreviate is the same as the full name,
// there is no short form and the function must end as it would cause infinite recursion.
- // Checks if short form ($i letters from the beginning of surname) is contained in name to check
+ // Checks if short form ($i letters from the beginning of lastName) is contained in name to check
if (strlen($lastName) > $i && str_contains($lastNameToCheck, substr($lastName, 0, $i))) {
// Increase number of letters that should be used of the last name as it exists in the name to check
$i++;
@@ -41,7 +41,7 @@ private function buildLastNameAbbreviation(string $lastName, array $usersToCheck
return $shortName;
};
// Always privilege longest lastname abbreviation as it means that this length necessary
- if (strlen($builtLastName = $buildLastName($lastName, (string)$userToCheck->surname)) > strlen(
+ if (strlen($builtLastName = $buildLastName($lastName, (string)$userToCheck->lastName)) > strlen(
$abbreviatedLastName
)) {
$abbreviatedLastName = $builtLastName;
@@ -94,7 +94,7 @@ public function abbreviateUserNames(array $users): array
unset($usersToCheckAgainst[$userId]);
// Call recursive function which compares last name of currently iterated user with other users with same
// first name and returns the shortest version of non-duplicate lastname
- $lastNameAbbr = $this->buildLastNameAbbreviation((string)$user->surname, $usersToCheckAgainst);
+ $lastNameAbbr = $this->buildLastNameAbbreviation((string)$user->lastName, $usersToCheckAgainst);
$outputNames[(int)$userId] = $user->firstName . ' ' . $lastNameAbbr;
}
}
diff --git a/src/Domain/User/Service/UserUpdater.php b/src/Domain/User/Service/UserUpdater.php
index 3a5a9b9c..23126049 100644
--- a/src/Domain/User/Service/UserUpdater.php
+++ b/src/Domain/User/Service/UserUpdater.php
@@ -49,7 +49,7 @@ public function updateUser(int $userIdToChange, array $userValues): bool
// Check that keys are one of the database columns that may be updated
if (in_array($column, [
'first_name',
- 'surname',
+ 'last_name',
'email',
'status',
'user_role_id',
diff --git a/src/Domain/User/Service/UserValidator.php b/src/Domain/User/Service/UserValidator.php
index fb9b06fd..0350a4d6 100644
--- a/src/Domain/User/Service/UserValidator.php
+++ b/src/Domain/User/Service/UserValidator.php
@@ -33,16 +33,16 @@ public function validateUserValues(array $userValues, bool $isCreateMode = true)
// For the user, there are no optional fields meaning that if any field is passed, it has to contain a value.
$validator
- // First name and surname are required to have values if they're given so no allowEmptyString
+ // First name and lastName are required to have values if they're given so no allowEmptyString
->requirePresence('first_name', $isCreateMode, __('Field is required'))
->minLength('first_name', 2, __('Minimum length is %d', 2))
->maxLength('first_name', 100, __('Maximum length is %d', 100))
// Disallow empty strings as field is required
->notEmptyString('first_name', __('Required'))
- ->requirePresence('surname', $isCreateMode, __('Field is required'))
- ->minLength('surname', 2, __('Minimum length is %d', 2))
- ->maxLength('surname', 100, __('Maximum length is %d', 100))
- ->notEmptyString('surname', __('Required'))
+ ->requirePresence('last_name', $isCreateMode, __('Field is required'))
+ ->minLength('last_name', 2, __('Minimum length is %d', 2))
+ ->maxLength('last_name', 100, __('Maximum length is %d', 100))
+ ->notEmptyString('last_name', __('Required'))
->requirePresence('email', $isCreateMode, __('Field is required'))
// email() automatically disallows empty strings
->email('email', false, __('Invalid email'))
diff --git a/src/Domain/UserActivity/Service/UserActivityFinder.php b/src/Domain/UserActivity/Service/UserActivityFinder.php
index 8a5dcbdb..9f6ce9be 100644
--- a/src/Domain/UserActivity/Service/UserActivityFinder.php
+++ b/src/Domain/UserActivity/Service/UserActivityFinder.php
@@ -86,7 +86,7 @@ private function findUserActivitiesGroupedByDate(int|string|array $userIds): arr
if (count($userIds) > 1) {
$userRow = $this->userFinderRepository->findUserById((int)$userActivity->userId);
$userActivity->timeAndActionName = '
' . $userRow['first_name'] . ' '
- . $userRow['surname'] . ' • ' .
+ . $userRow['last_name'] . ' • ' .
$userActivity->timeAndActionName;
}
$formattedDate = ucfirst(
diff --git a/templates/user/user-read.html.php b/templates/user/user-read.html.php
index 63f053bf..a1224bca 100644
--- a/templates/user/user-read.html.php
+++ b/templates/user/user-read.html.php
@@ -60,8 +60,8 @@ class="contenteditable-edit-icon cursor-pointer"
id="edit-last-name-btn">
-
=
- !empty($user->surname) ? html($user->surname) : ' ' ?>
+
=
+ !empty($user->lastName) ? html($user->lastName) : ' ' ?>