Add new items listing and counting
This commit is contained in:
22
src/Controller/NewController.php
Normal file
22
src/Controller/NewController.php
Normal 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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user