Files
oficial/app/src/Model/Persona.php
Juan Pablo Vial 42e1dcdff7 Agregar Proveedor
2024-12-03 16:45:42 -03:00

48 lines
1.2 KiB
PHP

<?php
namespace Incoviba\Model;
use Incoviba\Common\Ideal;
use Incoviba\Model\Persona\Datos;
class Persona extends Ideal\Model
{
public int $rut;
public string $digito;
public string $nombres;
public string $apellidoPaterno;
public string $apellidoMaterno;
public function nombreCompleto(): string
{
return $this->nombres . ' ' . $this->apellidoPaterno . ' ' . $this->apellidoMaterno;
}
public function rutCompleto(): string
{
return number_format($this->rut, 0, ',', '.') . '-' . $this->digito;
}
protected ?Datos $datos;
public function datos(): ?Datos
{
if (!isset($this->datos)) {
$this->datos = $this->runFactory('datos');
}
return $this->datos;
}
public function jsonSerialize(): mixed
{
return [
'rut' => $this->rut,
'digito' => $this->digito,
'nombres' => $this->nombres,
'apellidoPaterno' => $this->apellidoPaterno,
'apellidoMaterno' => $this->apellidoMaterno,
'nombreCompleto' => $this->nombreCompleto(),
'rutCompleto' => $this->rutCompleto(),
'datos' => $this->datos() ?? null,
];
}
}