24 lines
676 B
PHP
24 lines
676 B
PHP
|
<?php
|
||
|
namespace Incoviba\Common\Controller;
|
||
|
|
||
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||
|
use Psr\Http\Message\ResponseInterface as Response;
|
||
|
use \Model;
|
||
|
use Incoviba\Common\Define\Controller\Json;
|
||
|
use Incoviba\Unidad;
|
||
|
|
||
|
class Unidades {
|
||
|
use Json;
|
||
|
|
||
|
public function facturas(Request $request, Response $response, $id_unidad): Response {
|
||
|
$unidad = Model::factory(Unidad::class)->find_one($id_unidad);
|
||
|
$output = [
|
||
|
'unidad' => $unidad->as_array(),
|
||
|
'facturas' => ($unidad->facturas()) ? array_map(function($item) {
|
||
|
return $item->as_array();
|
||
|
}, $unidad->facturas()) : null
|
||
|
];
|
||
|
return $this->withJson($response, $output);
|
||
|
}
|
||
|
}
|