Files
This commit is contained in:
@ -39,7 +39,7 @@ abstract class Model extends BaseModel implements ModelInterface {
|
||||
}
|
||||
return $definitions;
|
||||
}
|
||||
public function parentOf(string $child_class, array $definitions): ?array {
|
||||
public function parentOf(string $child_class, array $definitions): bool|array {
|
||||
$definitions = $this->validateDefinitions(
|
||||
$definitions,
|
||||
[Model::CHILD_KEY, Model::SELF_KEY],
|
||||
@ -48,7 +48,7 @@ abstract class Model extends BaseModel implements ModelInterface {
|
||||
$where = [[$definitions[Model::CHILD_KEY], $this->{$definitions[Model::SELF_KEY]}]];
|
||||
return $this->factory->find($child_class)->where($where)->many();
|
||||
}
|
||||
public function childOf(string $parent_class, array $definitions): ?ModelInterface {
|
||||
public function childOf(string $parent_class, array $definitions): bool|ModelInterface {
|
||||
$definitions = $this->validateDefinitions(
|
||||
$definitions,
|
||||
[Model::PARENT_KEY, Model::SELF_KEY],
|
||||
|
@ -45,6 +45,69 @@ class Ventas {
|
||||
'href' => str_replace("/venta/{$venta_id}", "/propiedad/{$venta->propiedad}", $request->getUri())
|
||||
]
|
||||
];
|
||||
if ($venta->pie()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'pie',
|
||||
'title' => 'Pie',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/pie/{$venta->pie}", $request->getUri())
|
||||
];
|
||||
}
|
||||
if ($venta->bono()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'bono_pie',
|
||||
'title' => 'Bono Pie',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/bono/{$venta->bono_pie}", $request->getUri())
|
||||
];
|
||||
}
|
||||
if ($venta->credito()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'credito',
|
||||
'title' => 'Credito',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/credito/{$venta->credito}", $request->getUri())
|
||||
];
|
||||
}
|
||||
if ($venta->escritura()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'escritura',
|
||||
'title' => 'Escritura',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/escritura/{$venta->escritura}", $request->getUri())
|
||||
];
|
||||
}
|
||||
if ($venta->subsidio()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'subsidio',
|
||||
'title' => 'Subsidio',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/subsidio/{$venta->subsidio}", $request->getUri())
|
||||
];
|
||||
}
|
||||
if ($venta->entrega()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'entrega',
|
||||
'title' => 'Entrega',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/entrega/{$venta->entrega}", $request->getUri())
|
||||
];
|
||||
}
|
||||
if ($venta->proyectoAgente()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'proyecto_agente',
|
||||
'title' => 'Proyecto Agente',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/proyecto_agente/{$venta->agente}", $request->getUri())
|
||||
];
|
||||
}
|
||||
if ($venta->promocion()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'promocion',
|
||||
'title' => 'Promocion',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/promocion/{$venta->promocion}", $request->getUri())
|
||||
];
|
||||
}
|
||||
if ($venta->resciliacion()) {
|
||||
$output['links'] []= [
|
||||
'rel' => 'resciliacion',
|
||||
'title' => 'Resciliacion',
|
||||
'href' => str_replace("/venta/{$venta_id}", "/resciliacion/{$venta->resciliacion}", $request->getUri())
|
||||
];
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function add(Request $request, Response $response, Factory $factory): Response {
|
||||
|
@ -21,7 +21,7 @@ interface Model {
|
||||
* @param array $definitions array of conditions for connecting to the child table
|
||||
* @return array|null
|
||||
*/
|
||||
public function parentOf(string $child_class, array $definitions): ?array;
|
||||
public function parentOf(string $child_class, array $definitions): bool|array;
|
||||
|
||||
/**
|
||||
* Get parent model of class {$parent_class}
|
||||
@ -29,7 +29,7 @@ interface Model {
|
||||
* @param array $definitions array of conditions for connecting to the parent table
|
||||
* @return Model|null
|
||||
*/
|
||||
public function childOf(string $parent_class, array $definitions): ?Model;
|
||||
public function childOf(string $parent_class, array $definitions): bool|Model;
|
||||
|
||||
/**
|
||||
* Get all siblings of class {$sibling_class}
|
||||
|
@ -2,5 +2,28 @@
|
||||
namespace Incoviba\Venta;
|
||||
|
||||
use Incoviba\API\Common\Alias\Model;
|
||||
use Incoviba\Common\Direccion;
|
||||
|
||||
class Agente extends Model {}
|
||||
/**
|
||||
* @property int $id
|
||||
* @property TipoAgente $tipo
|
||||
* @property int $rut
|
||||
* @property string $descripcion
|
||||
* @property string $representante
|
||||
* @property int $telefono
|
||||
* @property string $correo
|
||||
* @property Direccion $direccion
|
||||
* @property string $giro
|
||||
* @property string $abreviacion
|
||||
*/
|
||||
class Agente extends Model {
|
||||
public static $_table = 'agente';
|
||||
|
||||
protected $ats;
|
||||
public function agenteTipos() {
|
||||
if ($this->ats === null) {
|
||||
$this->ats = $this->parentOf(AgenteTipo::class, [Model::CHILD_KEY => 'agente']);
|
||||
}
|
||||
return $this->ats;
|
||||
}
|
||||
}
|
||||
|
31
src/Venta/AgenteTipo.php
Normal file
31
src/Venta/AgenteTipo.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Incoviba\Venta;
|
||||
|
||||
use Incoviba\API\Common\Alias\Model;
|
||||
|
||||
class AgenteTipo extends Model {
|
||||
public static $_table = 'agente_tipo';
|
||||
|
||||
protected $agente_o;
|
||||
public function agente() {
|
||||
if ($this->agente_o === null) {
|
||||
$this->agente_o = $this->childOf(Agente::class, [Model::SELF_KEY => 'agente']);
|
||||
}
|
||||
return $this->agente_o;
|
||||
}
|
||||
protected $tipo_o;
|
||||
public function tipo() {
|
||||
if ($this->tipo_o === null) {
|
||||
$this->tipo_o = $this->childOf(TipoAgente::class, [Model::SELF_KEY => 'tipo']);
|
||||
}
|
||||
return $this->tipo_o;
|
||||
}
|
||||
|
||||
protected $pas;
|
||||
public function proyectoAgentes() {
|
||||
if ($this->pas === null) {
|
||||
$this->pas = $this->parentOf(ProyectoAgente::class, [Model::CHILD_KEY => 'agente']);
|
||||
}
|
||||
return $this->pas;
|
||||
}
|
||||
}
|
24
src/Venta/ProyectoAgente.php
Normal file
24
src/Venta/ProyectoAgente.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\Venta;
|
||||
|
||||
use Incoviba\API\Common\Alias\Model;
|
||||
use Incoviba\Proyecto\Proyecto;
|
||||
|
||||
class ProyectoAgente extends Model {
|
||||
public static $_table = 'proyecto_agente';
|
||||
|
||||
protected $at;
|
||||
public function agenteTipo() {
|
||||
if ($this->at === null) {
|
||||
$this->at = $this->childOf(AgenteTipo::class, [Model::SELF_KEY => 'agente']);
|
||||
}
|
||||
return $this->at;
|
||||
}
|
||||
protected $proyecto_o;
|
||||
public function proyecto() {
|
||||
if ($this->proyecto_o === null) {
|
||||
$this->proyecto_o = $this->childOf(Proyecto::class, [Model::SELF_KEY => 'proyecto']);
|
||||
}
|
||||
return $this->proyecto_o;
|
||||
}
|
||||
}
|
16
src/Venta/TipoAgente.php
Normal file
16
src/Venta/TipoAgente.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Incoviba\Venta;
|
||||
|
||||
use Incoviba\API\Common\Alias\Model;
|
||||
|
||||
class TipoAgente extends Model {
|
||||
public static $_table = 'tipo_agente';
|
||||
|
||||
protected $ats;
|
||||
public function agentesTipos() {
|
||||
if ($this->ats === null) {
|
||||
$this->ats = $this->parentOf(AgenteTipo::class, [Model::CHILD_KEY => 'tipo']);
|
||||
}
|
||||
return $this->ats;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ use Incoviba\API\Common\Alias\Model;
|
||||
* @property ?Escritura $escritura
|
||||
* @property ?Subsidio $subsidio
|
||||
* @property ?DateTime $escriturado
|
||||
* @property ?Entrega $entrga
|
||||
* @property ?Entrega $entrega
|
||||
* @property ?DateTime $entregado
|
||||
* @property DateTime $fecha
|
||||
* @property double $valor_uf
|
||||
@ -90,12 +90,12 @@ class Venta extends Model {
|
||||
}
|
||||
return $this->entrega_o;
|
||||
}
|
||||
protected $agente_o;
|
||||
public function agente() {
|
||||
if ($this->agente_o === null) {
|
||||
$this->agente_o = $this->childOf(Agente::class, [Model::SELF_KEY => 'agente']);
|
||||
protected $pa;
|
||||
public function proyectoAgente() {
|
||||
if ($this->pa === null) {
|
||||
$this->pa = $this->childOf(ProyectoAgente::class, [Model::SELF_KEY => 'agente']);
|
||||
}
|
||||
return $this->agente_o;
|
||||
return $this->pa;
|
||||
}
|
||||
protected $promocion_o;
|
||||
public function promocion() {
|
||||
|
Reference in New Issue
Block a user