API 1.0.0-rc
This commit is contained in:
44
api/src/Fuente.php
Normal file
44
api/src/Fuente.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace Contabilidad;
|
||||
|
||||
use ProVM\Common\Alias\Model;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property TipoFuente $tipo_id
|
||||
* @property Banco $banco_id
|
||||
*/
|
||||
class Fuente extends Model {
|
||||
public static $_table = 'fuentes';
|
||||
protected static $fields = ['tipo_id', 'banco_id'];
|
||||
|
||||
protected $tipo;
|
||||
public function tipo() {
|
||||
if ($this->tipo === null) {
|
||||
$this->tipo = $this->childOf(TipoFuente::class, [Model::SELF_KEY => 'tipo_id']);
|
||||
}
|
||||
return $this->tipo;
|
||||
}
|
||||
protected $banco;
|
||||
public function banco() {
|
||||
if ($this->banco === null) {
|
||||
$this->banco = $this->childOf(Banco::class, [Model::SELF_KEY => 'banco_id']);
|
||||
}
|
||||
return $this->banco;
|
||||
}
|
||||
|
||||
protected $entradas;
|
||||
public function entradas() {
|
||||
if ($this->entradas === null) {
|
||||
$this->entradas = $this->parentOf(Entrada::class, [Model::CHILD_KEY => 'fuente_id']);
|
||||
}
|
||||
return $this->entradas;
|
||||
}
|
||||
|
||||
public function toArray(): array {
|
||||
$arr = parent::toArray();
|
||||
$arr['tipo'] = $this->tipo()->toArray();
|
||||
$arr['banco'] = $this->banco()->toArray();
|
||||
return $arr;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user