API
This commit is contained in:
31
api/common/Controller/Ventas.php
Normal file
31
api/common/Controller/Ventas.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user