src/Controller/HomeController.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Nuptials;
  4. use App\Repository\BannerRepository;
  5. use App\Repository\GalleryRepository;
  6. use App\Repository\NuptialsGalleryRepository;
  7. use App\Repository\NuptialsRepository;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class HomeController extends AbstractController
  12. {
  13.     #[Route('/'name'home')]
  14.     public function index(BannerRepository $bannerRepositoryGalleryRepository $galleryRepository): Response
  15.     {
  16.         $gallery = [];
  17.         $i 0;
  18.         foreach ($galleryRepository->findby([], ["ordine" => "ASC"]) as $item) {
  19.             $gallery[$i 3][] = $item;
  20.             $i++;
  21.         }
  22.         return $this->render('home/index.html.twig', [
  23.             'banner' => $bannerRepository->findAll(),
  24.             'gallery' => $gallery
  25.         ]);
  26.     }
  27.     #[Route('/weddings'name'weddings')]
  28.     public function weddings(NuptialsRepository $nuptialsRepository): Response
  29.     {
  30.         return $this->render('home/weddings.html.twig', [
  31.             'weddings' => $nuptialsRepository->findAll(),
  32.         ]);
  33.     }
  34.     #[Route('/wedding/{id}'name'wedding')]
  35.     public function wedding(Nuptials $nuptialsNuptialsGalleryRepository  $nuptialsGalleryRepository): Response
  36.     {
  37.         $gallery = [];
  38.         $i 0;
  39.         $three_photos = [];
  40.         foreach ($nuptialsGalleryRepository->findby(['nuptial' => $nuptials], ["ordine" => "ASC"]) as $item) {
  41.             if ($item->getOrdine() >= && $item->getOrdine() <= 3) {
  42.                 $three_photos[] = $item;
  43.             } else {
  44.                 $gallery[$i 3][] = $item;
  45.             }
  46.             $i++;
  47.         }
  48.         return $this->render('home/wedding_detail.html.twig', [
  49.             'wedding' => $nuptials,
  50.             'three_photos' => $three_photos,
  51.             'gallery' => $gallery
  52.         ]);
  53.     }
  54.     #[Route('/contact'name'contact')]
  55.     public function contact(): Response
  56.     {
  57.         return $this->render('home/contact.html.twig');
  58.     }
  59. }