From 51fb951b2bbd29e7a922ca042da456081bce6a37 Mon Sep 17 00:00:00 2001 From: lubiana Date: Sat, 14 Jun 2025 21:39:20 +0200 Subject: [PATCH] oha --- src/Controller/Index.php | 12 +++++++++--- templates/index.html.twig | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Controller/Index.php b/src/Controller/Index.php index 9c68aae..093259d 100644 --- a/src/Controller/Index.php +++ b/src/Controller/Index.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Controller; use App\Repository\DrinkTypeRepository; +use App\Service\DrinkType\FilterLowStockDrinks; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -12,10 +13,15 @@ use Symfony\Component\Routing\Attribute\Route; #[Route(path: '/', name: 'app_index')] final class Index extends AbstractController { - public function __invoke(DrinkTypeRepository $drinkTypeRepository): Response - { + public function __invoke( + DrinkTypeRepository $drinkTypeRepository, + FilterLowStockDrinks $filterLowStockDrinks + ): Response { + $wanted = $drinkTypeRepository->findWanted(); + $lowStock = $filterLowStockDrinks($wanted); return $this->render('index.html.twig', [ - 'drinkTypes' => $drinkTypeRepository->findWanted(), + 'drinkTypes' => $lowStock, + 'lowStock' => $lowStock, ]); } diff --git a/templates/index.html.twig b/templates/index.html.twig index 68e5a44..f47735b 100644 --- a/templates/index.html.twig +++ b/templates/index.html.twig @@ -5,8 +5,22 @@ {% block body %}

Drink Inventory

+ {% if lowStock != [] %}
-
+
+
LOW STOCK ALERT
+
+
+
    + {% for drinkType in lowStock %} +
  • {{ drinkType.name }} ({{ drinkType.currentStock }} / {{ drinkType.wantedStock }})
  • + {% endfor %} +
+
+
+ {% endif %} +
+
Drink Inventory Overview