Order by starred flag and create date in promos view #7

Merged
krzysiej merged 1 commits from fix/ordering-promo-items into master 2024-11-21 09:46:03 +01:00
Showing only changes of commit 0e8c312f5e - Show all commits

View File

@@ -12,7 +12,11 @@ final class PromosController extends BaseController
#[Route('/promos', name: 'app_promos')] #[Route('/promos', name: 'app_promos')]
public function __invoke(): Response 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]); return $this->render('productList.html.twig', ['products' => $products]);
} }
} }