mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
31 lines
809 B
PHP
31 lines
809 B
PHP
<?php
|
|
namespace App\Entities\Usuarios;
|
|
|
|
use CodeIgniter\Shield\Entities\User;
|
|
|
|
class UsersEntity extends User
|
|
{
|
|
protected $attributes = [
|
|
'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"];
|
|
}
|
|
|
|
|
|
}
|