From 0e8c312f5e97cc0050993ddfc880b21e85d81f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20P=C5=82aczek?= Date: Thu, 21 Nov 2024 09:45:31 +0100 Subject: [PATCH] Order by starred flag and create date in promos view --- src/Controller/PromosController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Controller/PromosController.php b/src/Controller/PromosController.php index 05319b1..a25825b 100644 --- a/src/Controller/PromosController.php +++ b/src/Controller/PromosController.php @@ -12,7 +12,11 @@ final class PromosController extends BaseController #[Route('/promos', name: 'app_promos')] public function __invoke(): Response { - $products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->with(['currentPrice'])->get(); + $products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice')) + ->orderByDesc('starred') + ->orderByDesc('created_by') + ->with(['currentPrice']) + ->get(); return $this->render('productList.html.twig', ['products' => $products]); } }