<?php
namespace App\Controller;
use App\Entity\Nuptials;
use App\Repository\BannerRepository;
use App\Repository\GalleryRepository;
use App\Repository\NuptialsGalleryRepository;
use App\Repository\NuptialsRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
#[Route('/', name: 'home')]
public function index(BannerRepository $bannerRepository, GalleryRepository $galleryRepository): Response
{
$gallery = [];
$i = 0;
foreach ($galleryRepository->findby([], ["ordine" => "ASC"]) as $item) {
$gallery[$i % 3][] = $item;
$i++;
}
return $this->render('home/index.html.twig', [
'banner' => $bannerRepository->findAll(),
'gallery' => $gallery
]);
}
#[Route('/weddings', name: 'weddings')]
public function weddings(NuptialsRepository $nuptialsRepository): Response
{
return $this->render('home/weddings.html.twig', [
'weddings' => $nuptialsRepository->findAll(),
]);
}
#[Route('/wedding/{id}', name: 'wedding')]
public function wedding(Nuptials $nuptials, NuptialsGalleryRepository $nuptialsGalleryRepository): Response
{
$gallery = [];
$i = 0;
$three_photos = [];
foreach ($nuptialsGalleryRepository->findby(['nuptial' => $nuptials], ["ordine" => "ASC"]) as $item) {
if ($item->getOrdine() >= 1 && $item->getOrdine() <= 3) {
$three_photos[] = $item;
} else {
$gallery[$i % 3][] = $item;
}
$i++;
}
return $this->render('home/wedding_detail.html.twig', [
'wedding' => $nuptials,
'three_photos' => $three_photos,
'gallery' => $gallery
]);
}
#[Route('/contact', name: 'contact')]
public function contact(): Response
{
return $this->render('home/contact.html.twig');
}
}