Order by starred flag and create date in promos view

This commit is contained in:
Krzysztof Płaczek
2024-11-21 09:45:31 +01:00
parent 685bff3ffc
commit 0e8c312f5e

View File

@@ -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]);
}
}