26 lines
831 B
PHP
26 lines
831 B
PHP
<?php
|
|
|
|
namespace Krzysiej\RyobiCrawler\Controller;
|
|
|
|
use Krzysiej\RyobiCrawler\Models\Product;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
|
final class PromosController extends BaseController
|
|
{
|
|
#[Route('/promos', name: 'app_promos')]
|
|
public function __invoke(): Response
|
|
{
|
|
if($this->cache->getItem('list_promos')->isHit()) {
|
|
return $this->render('productList.html.twig', ['listType' => 'promos']);
|
|
}
|
|
|
|
$products = Product::whereRaw('priceCurrent < productStandardPrice')
|
|
->orderByDesc('starred')
|
|
->orderByDesc('created_by')
|
|
->with(['currentPrice', 'lowestPrice'])
|
|
->get();
|
|
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'promos']);
|
|
}
|
|
}
|