<?php
namespace App\Entities\Clientes;

use App\Models\Clientes\ClienteModel;
use CodeIgniter\Entity;

class ClienteContactoEntity extends \CodeIgniter\Entity\Entity
{
    protected $attributes = [
        "id" => null,
        "cliente_id" => null,
        "cargo" => null,
        "nombre" => null,
        "apellidos" => null,
        "telefono" => null,
        "email" => null,
        "is_deleted" => 0,
        "created_at" => null,
        "updated_at" => null,
    ];
    protected $casts = [
        "cliente_id" => "int",
        "is_deleted" => "int",
    ];

    public function getFullName() : string
    {
        return trim(implode(" ",[$this->attributes['nombre'] ?? '',$this->attributes["apellidos"] ?? '']));
    }
    public function cliente() : ?ClienteEntity
    {   
        $cm = model(ClienteModel::class);
        return $cm->find($this->attributes["cliente_id"]);
    }
}
