This commit is contained in:
2021-08-10 15:48:33 -04:00
parent a1519752cd
commit 2d4f48f3a9
39 changed files with 864 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<?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\Venta;
class Ventas {
use Json;
public function __invoke(Request $request, Response $response): Response {
$ventas = Model::factory(Venta::class)->find_array();
$output = compact('ventas');
return $this->withJson($response, $output);
}
public function show(Request $request, Response $response, $id_venta): Response {
$venta = Model::factory(Venta::class)->find_one($id_venta);
$output = ['venta' => $venta->as_array()];
return $this->withJson($response, $output);
}
public function operador(Request $request, Response $response, $id_venta): Response {
$venta = Model::factory(Venta::class)->find_one($id_venta);
$output = [
'venta' => $venta->as_array(),
'operador' => $venta->operador() ? $venta->operador()->as_array() : null
];
return $this->withJson($response, $output);
}
}