src/Controller/App/WidgetController.php line 42

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author <akartis-dev>
  4.  */
  5. namespace App\Controller\App;
  6. use App\Controller\AppAbstractController;
  7. use App\Entity\Pharmacists;
  8. use App\Repository\Application\SlidersRepository;
  9. use App\Repository\PharmacyNotificationRepository;
  10. use App\Repository\Products\Categories\ProductsCategoriesRepository;
  11. use App\Repository\Products\ProductBrandRepository;
  12. use App\Service\Cart\CartService;
  13. use App\Service\Gift\GiftService;
  14. use App\Service\Notifications\NotificationService;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\Response;
  17. class WidgetController extends AppAbstractController
  18. {
  19.     public function sliders(SlidersRepository $slidersRepository): Response
  20.     {
  21.         $sliders $slidersRepository->findBy(['isActive' => true], ['id' => 'ASC']);
  22.         return $this->render('elements/component/sliders.html.twig', [
  23.             'sliders' => $sliders
  24.         ]);
  25.     }
  26.     /**
  27.      * Online shop filter
  28.      *
  29.      * @param ProductsCategoriesRepository $productsCategoriesRepository
  30.      * @param ProductBrandRepository $brandRepository
  31.      * @param $linkMode
  32.      * @return Response
  33.      * @throws \JsonException
  34.      * @throws \Psr\Container\ContainerExceptionInterface
  35.      * @throws \Psr\Container\NotFoundExceptionInterface
  36.      */
  37.     public function onlineShopFilter(
  38.         ProductsCategoriesRepository $productsCategoriesRepository,
  39.         ProductBrandRepository       $brandRepository,
  40.                                      $linkMode false
  41.     ): Response
  42.     {
  43.         $request $this->container->get("request_stack")->getMainRequest();
  44.         $categories $productsCategoriesRepository->findByTree('fr');
  45.         $brands $brandRepository->findAll();
  46.         $q_categories json_decode(
  47.             $request->get("categories""[]"),
  48.             true,
  49.             512,
  50.             JSON_THROW_ON_ERROR
  51.         );
  52.         $q_brands json_decode(
  53.             $request->get('brands'"[]"),
  54.             true,
  55.             512,
  56.             JSON_THROW_ON_ERROR
  57.         );
  58.         $q_min $request->get("min"1);
  59.         $q_max $request->get("max"100);
  60.         $q_order $request->get("order"0);
  61.         $q_search $request->get("q"null);
  62.         return $this->render('elements/pagesElements/_online_shop_filter.html.twig', [
  63.             'categories' => $categories,
  64.             'brands' => $brands,
  65.             'q_categories' => $q_categories,
  66.             "q_brands" => $q_brands,
  67.             "q_min" => $q_min,
  68.             "q_max" => $q_max,
  69.             "q_order" => $q_order,
  70.             'linkMode' => $linkMode,
  71.             'q_search' => $q_search
  72.         ]);
  73.     }
  74.     public function headerCart(CartService $cartService): Response
  75.     {
  76.         $cart $cartService->getHydratedCart();
  77.         $count 0;
  78.         foreach ($cart as $cartItem) {
  79.             $count += $cartItem['quantity'];
  80.         }
  81.         return $this->render('elements/pagesElements/_header_cart.html.twig', [
  82.             'sum' => $cartService->getTotalBrut(),
  83.             "count" => $count
  84.         ]);
  85.     }
  86.     public function adminHeaderNotification(
  87.         PharmacyNotificationRepository $pharmacyNotificationRepository,
  88.         NotificationService            $notificationService
  89.     ): Response
  90.     {
  91.         /** @var Pharmacists $user */
  92.         $user $this->getUser();
  93.         $unreadCount $notificationService->getUnreadNotification($user->getPharmacyId());
  94.         $notifications $pharmacyNotificationRepository
  95.             ->findBy(['pharmacyId' => $user->getPharmacyId()], ['id' => 'DESC'], 15);
  96.         return $this->render('elements/pagesElements/_headerNotification.html.twig', [
  97.             'notifications' => $notifications,
  98.             'unreadCount' => $unreadCount
  99.         ]);
  100.     }
  101.     public function categoriesSideBar(
  102.         ProductsCategoriesRepository $productsCategoriesRepository
  103.     )
  104.     {
  105.         $categories $productsCategoriesRepository->findByTree("fr");
  106. //        dump($categories);
  107.         return $this->render('elements/pagesElements/_sidebar.html.twig', [
  108.             'categories' => $categories
  109.         ]);
  110.     }
  111.     public function giftsProduct(Request $requestGiftService $giftService)
  112.     {
  113.         $productId $request->get('product');
  114.         $cartGift $request->get('cartGift'false);
  115.         $items $giftService->handleViewInProduct($productId$cartGift);
  116. //        dd($items);
  117.         return $this->render('elements/products/_product_gift.html.twig', ['gifts' => $items'cardGift' => $cartGift]);
  118.     }
  119. }