<?php
namespace App\Controller;
use App\Entity\Post;
use App\Entity\Accueil;
use App\Entity\Blog;
use App\Entity\Prices;
use App\Entity\AncienEvenement;
use App\Entity\EvenementAVenir;
use App\Entity\Congre;
use App\Entity\Document;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Doctrine\Persistence\ManagerRegistry;
class IndexController extends AbstractController
{
public function index(ManagerRegistry $doctrine): Response
{
$product = $doctrine->getRepository(Accueil::class)->find(5);
$ancien = $doctrine->getRepository(AncienEvenement::class)->findAll();
$dernier_congre=$doctrine->getRepository(Congre::class)->findBy(array('desplay'=>1), array('id' => 'desc'),1,0);
$dernier_evenement=$doctrine->getRepository(EvenementAvenir::class)->findBy(array('desplay'=>1), array('id' => 'desc'),1,0);
$blog = $doctrine->getRepository(Blog::class)->findBy(array(), array('id' => 'desc'),6,0);
return $this->render('index/index.html.twig',['product'=>$product,'ancien'=>$ancien,'dernier_congre'=>$dernier_congre,'blog'=>$blog,'dernier_evenement'=>$dernier_evenement]);
}
public function apropos(ManagerRegistry $doctrine): Response
{
return $this->render('apropos/apropos.html.twig');
}
public function getDocumentByUser(ManagerRegistry $doctrine): Response
{
$id_user=1;
$nb=0;
$event = $doctrine->getRepository(EvenementAVenir::class)->findAll();
$document = $doctrine->getRepository(Document::class)->findAll();
$congre = $doctrine->getRepository(Congre::class)->findBy(array('userId' =>$id_user));
foreach($document as $a)
{
$congre = $doctrine->getRepository(Congre::class)->findBy(array('userId' =>$id_user,'titre' =>$a->getEvenementSelect()));
if($congre !=Null)
{
$nb++;
}
}
return new Response($nb);
}
}