saufen/src/Controller/Index.php
2025-06-14 22:43:27 +02:00

32 lines
949 B
PHP

<?php
declare(strict_types=1);
namespace App\Controller;
use App\Repository\DrinkTypeRepository;
use App\Service\DrinkType\FilterLowStockDrinks;
use App\Service\OrderService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
#[Route(path: '/', name: 'app_index')]
final class Index extends AbstractController
{
public function __invoke(
DrinkTypeRepository $drinkTypeRepository,
FilterLowStockDrinks $filterLowStockDrinks,
OrderService $orderService,
): Response {
$wanted = $drinkTypeRepository->findWanted();
$lowStock = $filterLowStockDrinks($wanted);
$orders = $orderService->getActiveOrders();
return $this->render('index.html.twig', [
'drinkTypes' => $lowStock,
'lowStock' => $lowStock,
'orders' => $orders,
]);
}
}