<?php
namespace App\Entities\Usuarios;

use CodeIgniter\Entity;

class UserEntity extends \CodeIgniter\Entity\Entity
{
    protected $attributes = [
        "id_user" => null,
        "first_name" => null,
        "last_name" => null,
        "date_birth" => null,
        "address" => "",
        "city" => "",
        "state" => "",
        "country" => "",
        "zip_code" => "",
        "mobile" => null,
        "email" => null,
        "password" => null,
        "last_ip" => null,
        "last_access" => null,
        "picture" => "/assets/img/default-user.png",
        "language" => null,
        "tfa" => false,
        "tfa_secret" => "",
        "tfa_code" => "",
        "blocked" => null,
        "email_confirmed" => 0,
        "token" => null,
        "status" => false,
        "created_at" => null,
        "updated_at" => null,
    ];
    protected $casts = [
        "tfa" => "boolean",
        "email_confirmed" => "int",
        "status" => "boolean",
    ];
    /**
     * Returns a full name: "first last"
     *
     * @return string
     */
    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;
    }

    /**
     * Alias for getFullName()
     *
     * @return string
     */
    public function fullName()
    {
        return $this->getFullName();
    }
}
