mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
54 lines
1.2 KiB
PHP
Executable File
54 lines
1.2 KiB
PHP
Executable File
<?php
|
|
namespace App\Entities\Clientes;
|
|
|
|
use CodeIgniter\Entity;
|
|
use App\Models\Clientes\ClienteModel;
|
|
use App\Models\Configuracion\PaisModel;
|
|
|
|
class ClienteDireccionesEntity extends \CodeIgniter\Entity\Entity
|
|
{
|
|
protected $attributes = [
|
|
"id" => null,
|
|
"cliente_id" => null,
|
|
"alias" => null,
|
|
"att" => null,
|
|
"email" => null,
|
|
"direccion" => null,
|
|
"pais_id" => null,
|
|
"provincia" => null,
|
|
"municipio" => null,
|
|
"cp" => null,
|
|
"telefono" => null,
|
|
];
|
|
protected $casts = [
|
|
"cliente_id" => "int",
|
|
"pais_id" => "int",
|
|
"cp" => "int",
|
|
];
|
|
|
|
public function getClienteNombre(): ?string
|
|
{
|
|
if (!$this->cliente_id) {
|
|
return null;
|
|
}
|
|
|
|
$clienteModel = model(ClienteModel::class);
|
|
$cliente = $clienteModel->find($this->cliente_id);
|
|
|
|
return $cliente ? $cliente->nombre : null;
|
|
}
|
|
|
|
public function getPaisNombre(): ?string
|
|
{
|
|
if (!$this->pais_id) {
|
|
return null;
|
|
}
|
|
|
|
$paisModel = model(PaisModel::class);
|
|
$pais = $paisModel->find($this->pais_id);
|
|
|
|
return $pais ? $pais->nombre : null;
|
|
}
|
|
|
|
}
|