Implemented repository mapper, and venta show
This commit is contained in:
@ -4,6 +4,7 @@ namespace Incoviba\Repository\Venta;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
@ -19,24 +20,17 @@ class EstadoPago extends Ideal\Repository
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = [
|
||||
'pago' => [
|
||||
'function' => function($data) {
|
||||
$map = (new Implement\Repository\MapperParser())
|
||||
->register('pago', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
return $this->pagoRepository->fetchById($data['pago']);
|
||||
}
|
||||
],
|
||||
'estado' => [
|
||||
'property' => 'tipoEstadoPago',
|
||||
'function' => function($data) {
|
||||
}))
|
||||
->register('estado', (new Implement\Repository\Mapper())
|
||||
->setProperty('tipoEstadoPago')
|
||||
->setFunction(function($data) {
|
||||
return $this->tipoEstadoPagoRepository->fetchById($data['estado']);
|
||||
}
|
||||
],
|
||||
'fecha' => [
|
||||
'function' => function($data) {
|
||||
return new DateTimeImmutable($data['fecha']);
|
||||
}
|
||||
]
|
||||
];
|
||||
}))
|
||||
->register('fecha', new Implement\Repository\Mapper\DateTime('fecha'));
|
||||
return $this->parseData(new Model\Venta\EstadoPago(), $data, $map);
|
||||
}
|
||||
|
||||
@ -59,6 +53,14 @@ class EstadoPago extends Ideal\Repository
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `pago` = ?";
|
||||
return $this->fetchMany($query, [$pago_id]);
|
||||
}
|
||||
public function fetchCurrentByPago(int $pago_id): Define\Model
|
||||
{
|
||||
$query = "SELECT a.*
|
||||
FROM `{$this->getTable()}` a
|
||||
JOIN (SELECT MAX(`id`) AS 'id', `pago` FROM `{$this->getTable()}` GROUP BY `pago`) e0 ON e0.`id` = a.`id`
|
||||
WHERE a.`pago` = ?";
|
||||
return $this->fetchOne($query, [$pago_id]);
|
||||
}
|
||||
public function fetchByPagoAndEstado(int $pago_id, int $estado_id): Define\Model
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `pago` = ? AND `estado` = ?";
|
||||
|
Reference in New Issue
Block a user