Start working on sorting products by different columns.

This commit is contained in:
Krzysztof Płaczek
2025-01-27 12:10:15 +01:00
parent a26ad401df
commit 9b6bcd22be
5 changed files with 25 additions and 8 deletions

View File

@@ -3,18 +3,17 @@
namespace Krzysiej\RyobiCrawler\Controller;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
final class IndexController extends BaseController
{
#[Route('/', name: 'app_home')]
public function __invoke(): Response
public function __invoke(Request $request): Response
{
$products = Product::with(['currentStock', 'price'])
->orderByDesc('starred')
->orderByDesc('created_by')
->get();
$products = Product::with(['currentStock', 'price', 'currentPrice']);
$products = $this->handleOrderProducts($products, $request)->get();
return $this->render('productList.html.twig', ['products' => $products]);
}
}