Reservations
This commit is contained in:
@ -14,8 +14,8 @@ use Incoviba\Repository;
|
||||
|
||||
class Reservation extends Ideal\Service\API
|
||||
{
|
||||
public function __construct(LoggerInterface $logger,
|
||||
protected Repository\Venta\Reservation $reservationRepository,
|
||||
public function __construct(LoggerInterface $logger,
|
||||
protected Repository\Venta\Reservation $reservationRepository,
|
||||
protected Repository\Venta\Reservation\State $stateRepository)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
@ -29,6 +29,14 @@ class Reservation extends Ideal\Service\API
|
||||
return [];
|
||||
}
|
||||
}
|
||||
public function getByProject(int $project_id): array
|
||||
{
|
||||
try {
|
||||
return array_map([$this, 'process'], $this->reservationRepository->fetchByProject($project_id));
|
||||
} catch (Implement\Exception\EmptyResult $exception) {
|
||||
throw new ServiceAction\Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
public function get(int $id): Model\Venta\Reservation
|
||||
{
|
||||
@ -39,6 +47,48 @@ class Reservation extends Ideal\Service\API
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $project_id
|
||||
* @return array
|
||||
* @throws ServiceAction\Read
|
||||
*/
|
||||
public function getActive(int $project_id): array
|
||||
{
|
||||
try {
|
||||
return array_map([$this, 'process'], $this->reservationRepository->fetchActive($project_id));
|
||||
} catch (Implement\Exception\EmptyResult $exception) {
|
||||
throw new ServiceAction\Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $project_id
|
||||
* @return array
|
||||
* @throws ServiceAction\Read
|
||||
*/
|
||||
public function getPending(int $project_id): array
|
||||
{
|
||||
try {
|
||||
return array_map([$this, 'process'], $this->reservationRepository->fetchPending($project_id));
|
||||
} catch (Implement\Exception\EmptyResult $exception) {
|
||||
throw new ServiceAction\Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $project_id
|
||||
* @return array
|
||||
* @throws ServiceAction\Read
|
||||
*/
|
||||
public function getRejected(int $project_id): array
|
||||
{
|
||||
try {
|
||||
return array_map([$this, 'process'], $this->reservationRepository->fetchRejected($project_id));
|
||||
} catch (Implement\Exception\EmptyResult $exception) {
|
||||
throw new ServiceAction\Read(__CLASS__, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
public function add(array $data): Model\Venta\Reservation
|
||||
{
|
||||
try {
|
||||
|
Reference in New Issue
Block a user