Merge branch 'main' into 'feat/edit_factura'

Main

See merge request jjimenez/safekat!292
This commit is contained in:
2024-07-17 07:55:06 +00:00
19 changed files with 386 additions and 2356 deletions

View File

@ -24,18 +24,25 @@ class UserEntity extends \CodeIgniter\Entity\Entity
"cliente_id" => "int",
"active" => "boolean",
];
/**
* Returns a full name: "first last"
* Get the full name of the user
*
* @return string
* If the first name and last name are available, the full name is generated as "{first name} {last name}".
* If the first name or last name is missing, only the available name is used.
* If both the first name and last name are missing, the username is used as the full name.
*
* @return string The full name of the user
*/
public function getFullName()
{
$fullName =
(!empty($this->attributes["first_name"]) ? trim($this->attributes["first_name"]) . " " : "") .
(!empty($this->attributes["last_name"]) ? trim($this->attributes["last_name"]) : "");
$name = empty($fullName) ? $this->attributes["username"] : $fullName;
return $name;
$firstName = trim($this->attributes["first_name"] ?? "");
$lastName = trim($this->attributes["last_name"] ?? "");
$fullName = $firstName . ' ' . $lastName;
$fullName = trim($fullName); // In case first name is empty, this will remove the leading space
// Use the username attribute if the full name is still empty after trimming
return $fullName ?: $this->attributes["username"];
}
/**

View File

@ -1,16 +1,30 @@
<?php
namespace App\Entities\Usuarios;
use CodeIgniter\Entity;
use CodeIgniter\Shield\Entities\User;
class UsersEntity extends User
{
protected $attributes = [
"first_name" => null,
"last_name" => null
'first_name' => null,
'last_name'=> null,
'cliente_id' => null,
'comments' => null,
];
protected $casts = [
"cliente_id" => "int",
];
public function getFullName()
{
$firstName = trim($this->attributes["first_name"] ?? "");
$lastName = trim($this->attributes["last_name"] ?? "");
$fullName = $firstName . ' ' . $lastName;
$fullName = trim($fullName); // In case first name is empty, this will remove the leading space
// Use the username attribute if the full name is still empty after trimming
return $fullName ?: $this->attributes["username"];
}
}