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}
|
||||
|
Reference in New Issue
Block a user