45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
|
<?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;
|
||
|
}
|
||
|
}
|