Files
oficial/app/common/Ideal/Model.php
Juan Pablo Vial 454ba41d9c Reservas
2025-08-22 09:28:53 -04:00

39 lines
793 B
PHP

<?php
namespace Incoviba\Common\Ideal;
use Incoviba\Common\Define;
abstract class Model implements Define\Model
{
public int $id;
protected array $factories;
public function addFactory(string $property, Define\Repository\Factory $factory): Model
{
$this->factories[$property] = $factory;
return $this;
}
protected function runFactory(string $property): mixed
{
if (isset($this->factories[$property])) {
return $this->factories[$property]->run();
}
return null;
}
public function jsonSerialize(): mixed
{
return [
'id' => $this->id ?? '',
...$this->jsonComplement()
];
}
protected function jsonComplement(): array
{
return [];
}
}