Add new items listing and counting

This commit is contained in:
2025-01-05 16:19:49 +01:00
parent 44254ed12a
commit 14104f61a4
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
namespace Krzysiej\RyobiCrawler\Controller;
use Illuminate\Database\Eloquent\Builder;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
final class NewController extends BaseController
{
#[Route('/promos', name: 'app_new')]
public function __invoke(): Response
{
$products = Product::whereHas('created_at', now()->subDays(30)->format('Y-m-d'))
->orderByDesc('starred')
->orderByDesc('created_by')
->with(['currentPrice'])
->get();
return $this->render('productList.html.twig', ['products' => $products]);
}
}