Implemented repository mapper, and venta show
This commit is contained in:
22
app/src/Controller/Ventas/Comentarios.php
Normal file
22
app/src/Controller/Ventas/Comentarios.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class Comentarios
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Comentario $comentarioRepository): ResponseInterface
|
||||
{
|
||||
$output = ['total' => 0];
|
||||
try {
|
||||
$comentarios = $comentarioRepository->fetchAll();
|
||||
$output['comentarios'] = $comentarios;
|
||||
$output['total'] = count($comentarios);
|
||||
} catch (EmptyResult) {}
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user