32 lines
1.1 KiB
PHP
32 lines
1.1 KiB
PHP
![]() |
<?php
|
||
|
namespace Incoviba\Controller;
|
||
|
|
||
|
use Psr\Http\Message\ResponseInterface;
|
||
|
use Psr\Http\Message\ServerRequestInterface;
|
||
|
use Incoviba\Common\Alias\View;
|
||
|
use Incoviba\Common\Implement\Exception\{EmptyResult, EmptyRedis};
|
||
|
use Incoviba\Repository;
|
||
|
use Incoviba\Service;
|
||
|
|
||
|
class Contabilidad
|
||
|
{
|
||
|
use withRedis;
|
||
|
|
||
|
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||
|
Service\Redis $redisService,
|
||
|
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||
|
{
|
||
|
$redisKey = 'inmobiliarias';
|
||
|
$inmobiliarias = [];
|
||
|
try {
|
||
|
$inmobiliarias = $this->fetchRedis($redisService, $redisKey);
|
||
|
} catch (EmptyRedis) {
|
||
|
try {
|
||
|
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
||
|
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
||
|
} catch (EmptyResult) {}
|
||
|
}
|
||
|
return $view->render($response, 'contabilidad.cartolas.diaria', compact('inmobiliarias'));
|
||
|
}
|
||
|
}
|