API 1.0.0-rc

This commit is contained in:
2021-07-27 22:29:56 -04:00
parent c2d7729e71
commit 6172da2f95
33 changed files with 1013 additions and 0 deletions

36
api/src/Cuenta.php Normal file
View File

@ -0,0 +1,36 @@
<?php
namespace Contabilidad;
use ProVM\Common\Alias\Model;
/**
* @property int $id
* @property string $nombre
* @property Categoria $categoria_id
*/
class Cuenta extends Model {
public static $_table = 'cuentas';
protected static $fields = ['nombre', 'categoria_id'];
protected $categoria;
public function categoria() {
if ($this->categoria === null) {
$this->categoria = $this->childOf(Categoria::class, [Model::SELF_KEY => 'categoria_id']);
}
return $this->categoria;
}
protected $entradas;
public function entradas() {
if ($this->entradas === null) {
$this->entradas = $this->parentOf(Entrada::class, [Model::CHILD_KEY => 'cuenta_id']);
}
return $this->entradas;
}
public function toArray(): array {
$arr = parent::toArray();
$arr['categoria'] = $this->categoria()->toArray();
return $arr;
}
}