src/Flexy/FrontBundle/Controller/HomeController.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Flexy\FrontBundle\Controller;
  3. use App\Flexy\FrontBundle\Entity\PubBanner;
  4. use App\Flexy\FrontBundle\Repository\CategoryProductFrontRepository;
  5. use App\Flexy\FrontBundle\Repository\MasterSliderRepository;
  6. use App\Flexy\FrontBundle\Repository\PubBannerRepository;
  7. use App\Flexy\ShopBundle\Repository\Product\ProductRepository;
  8. use App\Flexy\FrontBundle\Repository\ProductFrontRepository;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Symfony\Component\HttpFoundation\Request;
  13. class HomeController extends AbstractController
  14. {
  15.     #[Route('/'name'multi_access')]
  16.     public function multiAccess
  17.     ProductFrontRepository $productRepository,
  18.     MasterSliderRepository $masterSliderRepository,
  19.     PubBannerRepository $pubBannerRepository,
  20.     CategoryProductFrontRepository $categoryProductFrontRepository): Response
  21.     {
  22.         $deals $productRepository->findDeals();
  23.         if($this->getUser() != null && $this->getUser()->getRoles()[0] == "ROLE_CUSTOMER"){
  24.             return $this->render('@Flexy\FrontBundle/templates/home/index.html.twig', [
  25.                 'products' => $productRepository->findAll(),
  26.                 'masterSliders'=> $masterSliderRepository->findBy(["isEnabled"=>true]),
  27.                 'pubBanners'=> $pubBannerRepository->findBy(["isEnabled"=>true]),
  28.                 'deals'=>$deals,
  29.                 'categoriesProduct'=> $categoryProductFrontRepository->findBy(["parentCategory"=>null])
  30.             ]);
  31.         }else{
  32.         return $this->render('@Flexy\FrontBundle/templates/home/multiAccess.html.twig');
  33.     }
  34.     }
  35.     #[Route('/marketplace'name'front_home')]
  36.     public function index(
  37.         ProductFrontRepository $productRepository,
  38.         MasterSliderRepository $masterSliderRepository,
  39.         PubBannerRepository $pubBannerRepository,
  40.         CategoryProductFrontRepository $categoryProductFrontRepository
  41.         
  42.         ): Response
  43.     {
  44.         $deals $productRepository->findDeals();
  45.         
  46.         return $this->render('@Flexy\FrontBundle/templates/home/index.html.twig', [
  47.             'products' => $productRepository->findAll(),
  48.             'masterSliders'=> $masterSliderRepository->findBy(["isEnabled"=>true]),
  49.             'pubBanners'=> $pubBannerRepository->findBy(["isEnabled"=>true]),
  50.             'deals'=>$deals,
  51.             'categoriesProduct'=> $categoryProductFrontRepository->findBy(["parentCategory"=>null])
  52.         ]);
  53.     }
  54.     #[Route('/contact'name'contact')]
  55.     public function contact(Request $request,ProductRepository $productRepository,\Swift_Mailer $mailer,): Response
  56.     {
  57.        
  58.          
  59.         if ($request->isMethod('POST')) {
  60.             
  61.             $name=$request->request->get("customerName");
  62.             $email=$request->request->get("customerEmail");
  63.             $subject=$request->request->get("contactSujet");
  64.             $contenu=$request->request->get("contactMessage");
  65.              
  66.              $message = (new \Swift_Message("Page contact O'mall"))
  67.              ->setFrom(['contact@omall.ma'=>"O'Mall"])
  68.              ->setTo(['contact.info@o-mall.ma'=>"Page contact O'mall"])
  69.              ->setBody(
  70.              $this->renderView(
  71.                 '@Flexy/FrontBundle/templates/registration/mail_frommarketplace.html.twig',
  72.                 [   
  73.                     "client"=>$name,
  74.                     "Email"=>$email,
  75.                     "subject"=>$subject,
  76.                     "message"=>$contenu
  77.                     ]
  78.                
  79.              ),
  80.                  'text/html'
  81.              );
  82.            
  83.              $mailer->send($message);  
  84.              if ($mailer->send($message))
  85.                 {
  86.                     $this->addFlash("success","Votre Email a été envoyer le service client omall va traité votre demande "); 
  87.                 }
  88.                  
  89.             
  90.         }
  91.         
  92.         
  93.         return $this->render('@Flexy\FrontBundle/templates/home/contact.html.twig', [
  94.             'products' => $productRepository->findAll(),
  95.         ]);
  96.     }
  97.     #[Route('/refund'name'refund_order')]
  98.     public function refund(ProductRepository $productRepository): Response
  99.     {
  100.         return $this->render('@Flexy\FrontBundle/templates/home/refundOrder.html.twig');
  101.     } 
  102.     
  103.     #[Route('/banner-block/{id}'name'pubBannerBlock')]
  104.     public function pubBannerBlock(PubBanner $pubBanner): Response
  105.     {
  106.         return $this->render('@Flexy\FrontBundle/templates/include-pubs/_singlePubBanner.html.twig', [
  107.             'singleBanner' => $pubBanner,
  108.         ]);
  109.     }
  110. }