Add external ID generation and update user route actions

Introduce methods to generate and retrieve unique external IDs for collected order invoices, ensuring UUID-based uniqueness. Update user route actions to include new functionalities for editing user roles and passwords.
This commit is contained in:
Jepp9350
2025-03-03 10:58:55 +01:00
parent e9aeedc327
commit b66c598f83
2 changed files with 33 additions and 1 deletions
@@ -19,6 +19,36 @@ class collected_order_invoices_o extends db
public object_property $created_at;
public object_property $updated_at;
public object_property $closed_at;
public array $processors = [
1 => 'E-conomic',
2 => 'Stripe',
];
/**
* Get the external id of the invoice collection
* @throws Exception If the request was not successful
* @throws Exception If the UUID could not be generated
* @throws Exception If the external id is not unique
*/
public function getExternalId(): string
{
if (empty($this->external_id->value())) {
$this->external_id->set(self::generateExternalId());
}
return $this->external_id->value();
}
/**
* Generate a unique external id (UUID)
* @return string The generated UUID
* @throws Exception If the UUID could not be generated
* @throws Exception If the request was not successful
*/
public static function generateExternalId(): string
{
$uuid = bin2hex(random_bytes(16));
return substr($uuid, 0, 8) . '-' . substr($uuid, 8, 4) . '-' . substr($uuid, 12, 4) . '-' . substr($uuid, 16, 4) . '-' . substr($uuid, 20);
}
public function structure(): void
{
+3 -1
View File
@@ -174,7 +174,9 @@ class usersRoute
}
},
[
'edit_user' => 'Edit a user'
'edit_user' => 'Edit a user',
'edit_user_role' => 'Edit a user\'s role',
'edit_user_password' => 'Edit a user\'s password'
]
);