Promo endpoint that display only products on sale.

This commit is contained in:
Krzysztof Płaczek
2024-10-18 11:24:46 +02:00
parent 53b6d33ab9
commit fee7495cfe
6 changed files with 69 additions and 7 deletions

View File

@@ -0,0 +1,15 @@
<?php
namespace Krzysiej\RyobiCrawler\Controller;
use Illuminate\Database\Eloquent\Builder;
use Krzysiej\RyobiCrawler\Models\Product;
final class PromosController extends BaseController
{
public function __invoke(): void
{
$products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->with(['currentPrice'])->get();
$this->twig->display('productList.html.twig', ['products' => $products]);
}
}