<file_sep><?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
 * Propriete
 *
 * @ORM\Table(name="propriete", indexes={@ORM\Index(name="IDX_73A85B935BA3388B", columns={"id_type_habitat_id"})})
 * @ORM\Entity
 */
class Propriete
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @Assert\Unique
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     * 
     * @ORM\Column(name="nom", type="string", length=40, nullable=false)
     */
    private $nom;

    /**
     * @var string
     *
     * @ORM\Column(name="type", type="string", length=30, nullable=false)
     */
    private $type;

    /**
     * @var bool
     *
     * @ORM\Column(name="obligatoire", type="boolean", nullable=false)
     */
    private $obligatoire;

    /**
     * @var \TypeHabitat
     *
     * @ORM\ManyToOne(targetEntity="TypeHabitat")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="id_type_habitat_id", referencedColumnName="id")
     * })
     */
    private $idTypeHabitat;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $image;




    public function __construct()
    {
        $this->image = "images/proprietes/2.png";


    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }

    public function getType(): ?string
    {
        return $this->type;
    }

    public function setType(string $type): self
    {
        $this->type = $type;

        return $this;
    }

    public function getObligatoire(): ?bool
    {
        return $this->obligatoire;
    }

    public function setObligatoire(bool $obligatoire): self
    {
        $this->obligatoire = $obligatoire;

        return $this;
    }


    public function getIdTypeHabitat(): ?TypeHabitat
    {
        return $this->idTypeHabitat;
    }

    public function setIdTypeHabitat(?TypeHabitat $idTypeHabitat): self
    {
        $this->idTypeHabitat = $idTypeHabitat;

        return $this;
    }

    public function getImage(): ?string
    {
        return $this->image;
    }

    public function setImage(string $image): self
    {
        $this->image = $image;

        return $this;
    }


}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class SearchContentController extends AbstractController
{
    /**
     * @Route("/search/content", name="search_content")
     */
    public function index(): Response
    {
        return $this->render('search_content/index.html.twig', [
            'controller_name' => 'SearchContentController',
        ]);
    }
}
<file_sep><?php

namespace App\Entity;

use App\Repository\CalendrierDomaineRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=CalendrierDomaineRepository::class)
 */
class CalendrierDomaine
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="date")
     */
    private $dateDispo;

    /**
     * @ORM\ManyToOne(targetEntity=Domaine::class, inversedBy="calendrierDomaines")
     */
    private $idDomaine;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getDateDispo(): ?\DateTimeInterface
    {
        return $this->dateDispo;
    }

    public function setDateDispo(\DateTimeInterface $dateDispo): self
    {
        $this->dateDispo = $dateDispo;

        return $this;
    }

    public function getIdDomaine(): ?Domaine
    {
        return $this->idDomaine;
    }

    public function setIdDomaine(?Domaine $idDomaine): self
    {
        $this->idDomaine = $idDomaine;

        return $this;
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Coordonnees;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class CoordonneesType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('civilite', ChoiceType::class, [
                'choices'  => [
                    'Madame' => "Madame",
                    'Monsieur' => "Monsieur",

                ],
                'expanded' => true,
                'multiple' => false,
                ])
            ->add('nom', TextType::class, [
                'attr' => array(
                    'placeholder' => 'Votre Nom'
                )
            ])
            ->add('prenom', TextType::class,  [
                'attr' => array(
                    'placeholder' => 'Votre Prénom'
                )
            ])
            ->add('email', EmailType::class,  [
                'attr' => array(
                    'placeholder' => '<EMAIL>'
                )
            ])
            ->add('telephone', NumberType::class,  [
                'attr' => array(
                    'placeholder' => 'Votre Numéro de Téléphone'
                )])
            ->add('adresse', TextType::class,  [
                'attr' => array(
                    'placeholder' => '123 Rue'
                )
            ])
            ->add('cp', NumberType::class,  [
                'attr' => array(
                    'placeholder' => 'Votre Code Postal'
                )
            ])
            ->add('ville', TextType::class,  [
                'attr' => array(
                    'placeholder' => 'Votre Ville',
                    'readonly' => true,


                ),
                'help' => 'Entrer votre code postal pour afficher votre ville',

            ])
            ->add('pays', CountryType::class,  [
                'preferred_choices' => ['FR'],
                ])
            ->add('save', SubmitType::class, [
                'attr' => ['class' => 'stripe-button'],

            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Coordonnees::class,
        ]);
    }
}
<file_sep><?php

namespace App\Controller;

use App\Entity\Propriete;
use App\Entity\Notification;
use App\Entity\ProprieteHabitat;
use App\Form\Propriete1Type;
use App\Repository\ProprieteRepository;
use App\Repository\ProprieteHabitatRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/propriete")
 */
class ProprieteController extends AbstractController
{
    /**
     * @Route("/", name="propriete_index", methods={"GET"})
     */
    public function index(ProprieteRepository $proprieteRepository): Response
    {
        return $this->render('propriete/index.html.twig', [
            'proprietes' => $proprieteRepository->findAll(),
        ]);
    }

    /**
     * @Route("/new", name="propriete_new", methods={"POST"})
     */
    public function new(Request $request): Response
    {
        $propriete = new Propriete();
        $notification = new Notification();
        $propriete_habitat = new ProprieteHabitat();
        $notification->setTitle("Ajout d'un paramètre");
        $form = $this->createForm(Propriete1Type::class, $propriete);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($propriete);

            $propriete_habitat->setIdPropriete($propriete->getId());
            $entityManager->persist($propriete_habitat);
            $notification->setContenu("Un nouveau paramètre vient d'être ajouté pour les ".$propriete->getIdTypeHabitat() );
            $notification->setTypeHabitat($propriete->getIdTypeHabitat());

            $entityManager->persist($notification);
            $entityManager->flush();
            return $this->redirectToRoute('propriete_index');
        }

        return $this->render('propriete/new.html.twig', [
            'propriete' => $propriete,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="propriete_show", methods={"GET"})
     */
    public function show(Propriete $propriete): Response
    {
        return $this->render('propriete/show.html.twig', [
            'propriete' => $propriete,
        ]);
    }

    /**
     * @Route("/{id}/edit", name="propriete_edit", methods={"GET","POST"})
     */
    public function edit(Request $request, Propriete $propriete): Response
    {
        $form = $this->createForm(Propriete1Type::class, $propriete);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('propriete_index');
        }

        return $this->render('propriete/edit.html.twig', [
            'propriete' => $propriete,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="propriete_delete", methods={"DELETE"})
     */
    public function delete(Request $request, Propriete $propriete): Response
    {
        if ($this->isCsrfTokenValid('delete'.$propriete->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($propriete);
            $entityManager->flush();
        }

        return $this->redirectToRoute('propriete_index');
    }
}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class PaiementController extends AbstractController
{
    /**
     * @Route("/paiement", name="paiement")
     */
    public function index(): Response
    {
        return $this->render('paiement/index.html.twig', [
            'controller_name' => 'PaiementController',
        ]);
    }
    /**
     * @Route("/etape/reservation", name="paiement")
     */
    public function stepReservation(): Response
    {
        return $this->render('paiement/index.html.twig', [
            'controller_name' => 'PaiementController',
        ]);
    }
}
<file_sep><?php

namespace App\DataFixtures;

use App\Entity\User;
use App\Entity\Activite;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;

class UserFixtures extends Fixture
{

    private $passwordEncoder ;

         public function __construct(UserPasswordEncoderInterface $passwordEncoder)
     {
         $this->passwordEncoder = $passwordEncoder;
     }
    public function load(ObjectManager $manager)
    {
        $product = new User() ;
        $product->setLogin("eshwar");
        $product->setRoles(["ROLE_USER"]);
        $product->setEmail("<EMAIL>");
        $product->setNom("eshwar");
        $product->setPrenom("tillai");
        $product->setAdresse("202 Rue Desaix");
        $product->setVille("Evry");
        $product->setCP("72000");
        $product->setDateNaissance(new \DateTime('now'));
        $product->setGenre("Homme");
        $product->setTelephone("0646437355");

        $password = $this->passwordEncoder->encodePassword($product, 'mdpasse');
        $product->setPassword($password);
        $manager->persist($product);
        $manager->flush();
    }
    
}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use App\Repository\UserRepository;
use App\Entity\User ;
use App\Entity\Habitat ;
use App\Entity\Location;
use App\Entity\Equipement;
use App\Entity\Commentaire;
use App\Entity\PriseDeVue;
use App\Util\UploadedBase64;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Routing\Annotation\Route;

class ApiPostController extends AbstractController
{
    /**
     * @Route("userss", name="userss" , methods={"GET"})
     */
    public function index(SerializerInterface $serializer): JsonResponse
    {
        $user = $this->getDoctrine()->getRepository(User::class)->findAll();
        $json = $serializer->serialize($user, 'json' , ['groups' => 'user:read']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }
    /**
     * @Route("display/{id}" , name="display" , methods={"GET"})
     */
    public function gettroisNotifications(int $id, SerializerInterface $serializer): JsonResponse
    {
            $idLocataire = $this->getDoctrine()->getRepository(User::class)->findOneBy([ 'id' => $id ]);
            $sql = 'SELECT DISTINCT (notification.id) , notification.titre, notification.contenu , notification.date_publication
            FROM type_habitat,habitat,domaine,notification
            WHERE type_habitat.id = habitat.id_type_habitat_id
            AND domaine.id = habitat.id_domaine_id 
            AND type_habitat.id = notification.id_type_habitat
            AND domaine.id_proprietaire_id  = '.$id.'
            AND notification.id_type_habitat IN (SELECT habitat.id_type_habitat_id
                                               FROM habitat)
            ORDER BY notification.date_publication DESC
            LIMIT 3';
            $em = $this->getDoctrine()->getManager();
            $stmt = $em->getConnection()->prepare($sql);
    
            $stmt->execute();
            $json = $serializer->serialize($stmt, 'json' , ['groups' => 'notification:info']);
            $response = new JsonResponse($json, 200, [], true);
    
            return $response;
    }
    /**
     * @Route("utilisateurs/{id}" , name="usersid" , methods={"GET"})
     */
    public function getUsersInfo(int $id, SerializerInterface $serializer): JsonResponse
    {
        $user = $this->getDoctrine()->getRepository(User::class)->findOneBy([ 'id' => $id]);
        $json = $serializer->serialize($user, 'json' , ['groups' => 'location:info']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }

    /**
     * @Route("connexion", name="connexion" , methods={"POST"})
     */
    public function loginUser(SerializerInterface $serializer, Request $request,UserPasswordEncoderInterface $encoder) : JsonResponse
    {
        $email = $request->query->get('email');
        $password = $request->query->get('password');
        $user = $this->getDoctrine()->getRepository(User::class)->findBy([ 'password' => $<PASSWORD>, 'email' => $email ]);
        $json = $serializer->serialize($user, 'json' , ['groups' => 'user:read']);
        $response = new JsonResponse($json, 200, [], true);
        return $response;
    }

    /**
     * @Route("habitatapp/{id}" , name="habitats_app" , methods={"GET"})
     */
    public function getHabitat(int $id, SerializerInterface $serializer): JsonResponse
    {
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->findBy([ 'id' => $id]);
        $json = $serializer->serialize($habitat, 'json' , ['groups' => 'location:info']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }

    /**
     * @Route("rental/{id}" , name="locations_app" , methods={"GET"})
     */
    public function getLocations(int $id, SerializerInterface $serializer): JsonResponse
    {
        $locataire = $this->getDoctrine()->getRepository(Location::class)->findBy([ 'idUserLocataire' => $id
]);
        $json = $serializer->serialize($locataire, 'json' , ['groups' => 'location:info']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }

    /**
     * @Route("equipement" , name="equipement_app" , methods={"GET"})
     */
    public function getEquipements(SerializerInterface $serializer): JsonResponse
    {
        $equiped = $this->getDoctrine()->getRepository(Equipement::class)->findAll();
        $json = $serializer->serialize($equiped, 'json' , ['groups' => 'location:info']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }
    /**
     * @Route("commentapp/{id}" , name="comment_app" , methods={"GET"})
     */
    public function getComments(int $id , SerializerInterface $serializer): JsonResponse
    {
        $comment = $this->getDoctrine()->getRepository(Commentaire::class)->findBy(['idHabitatIdCommentaire' => $id]);
        $json = $serializer->serialize($comment, 'json' , ['groups' => 'location:info']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }

    /**
     * @Route("photosapp/{id}" , name="photos_app" , methods={"GET"})
     */
    public function getPhotos(int $id , SerializerInterface $serializer): JsonResponse
    {
        $comment = $this->getDoctrine()->getRepository(PriseDeVue::class)->findBy(['idHabitatIdPrisedevue' => $id]);
        $json = $serializer->serialize($comment, 'json' , ['groups' => 'location:info']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }
    /**
     * @Route("addphotoapp" , name="photo_app_add" , methods={"POST"})
     */
    public function savePhotos(Request $request, SerializerInterface $serializer) : Response
    {
        $jsonRecu = $request->getContent();
        $photos = $serializer->deserialize($jsonRecu, PriseDeVue::class, 'json');
        $bien = $this->getDoctrine()->getRepository(Habitat::class)->findOneBy(['nom' => $photos->getIdHabitatIdPrisedevue()->getNom()]);
        $prisedevue = new PriseDeVue();
        $imageurl = $photos->getUrl();
        $img = "<img src= 'data:image/jpeg;base64, $imageurl' />";
        $fichier = md5(uniqid()).'.jpg';
        $directory = $this->getParameter('photo_directory');
        $success = file_put_contents($fichier, $img);
        $imageFile = new UploadedBase64($img, $fichier);
        $imageFile->move($directory, $fichier);
        $prisedevue->setUrl($fichier);
        $prisedevue->setIdHabitatIdPrisedevue($bien);
        $entityManager = $this->getDoctrine()->getManager();
        $entityManager->persist($prisedevue);
        $entityManager->flush();
        $response = new Response(
            'Content',
            Response::HTTP_OK,
            ['content-type' => 'text/html']
        );   
        return $response;
    }
    /**
     * @Route("addcommentapp" , name="comment_app_add" , methods={"POST"})
     */
    public function saveComment(Request $request, SerializerInterface $serializer)
    {
        $entityManager = $this->getDoctrine()->getManager();
        $jsonRecu = $request->getContent();
        $comment = $serializer->deserialize($jsonRecu, Commentaire::class, 'json');
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->findOneBy(['nom' => $comment->getIdHabitatIdCommentaire()->getNom()]);
        $user = $this->getDoctrine()->getRepository(User::class)->findOneBy(['email' => $comment->getIdUser()->getEmail()]);
        $commentaire = new Commentaire();
        $commentaire->setTitre($comment->getTitre());
        $commentaire->setContenu($comment->getContenu());
        $commentaire->setIdHabitatIdCommentaire($habitat);
        $commentaire->setIdUser($user);
        $entityManager->persist($commentaire);
        $entityManager->flush();

    }

    /**
     * @Route("notifs/{id}" , name="notifs" , methods={"GET"})
     */
    public function getNotifications(int $id, SerializerInterface $serializer): JsonResponse
    {
        $idLocataire = $this->getDoctrine()->getRepository(User::class)->findOneBy([ 'id' => $id ]);
        $sql = 'SELECT DISTINCT (notification.id) , notification.titre, notification.contenu , notification.date_publication
        FROM type_habitat,habitat,domaine,notification
        WHERE type_habitat.id = habitat.id_type_habitat_id
        AND domaine.id = habitat.id_domaine_id 
        AND type_habitat.id = notification.id_type_habitat
        AND domaine.id_proprietaire_id  = '.$id.'
        AND notification.id_type_habitat IN (SELECT habitat.id_type_habitat_id
                                           FROM habitat)
        ORDER BY notification.date_publication DESC';
        $em = $this->getDoctrine()->getManager();
        $stmt = $em->getConnection()->prepare($sql);

        $stmt->execute();
        $json = $serializer->serialize($stmt, 'json' , ['groups' => 'notification:info']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }
    /**
     * @Route("userlogin" , name="user_login_app" , methods={"POST"})
     */
    public function seConnecter(Request $request, SerializerInterface $serializer)
    {
        $entityManager = $this->getDoctrine()->getManager();
        $jsonRecu = $request->getContent();
        $loginsession = $serializer->deserialize($jsonRecu, User::class, 'json');
        $user = $this->getDoctrine()->getRepository(User::class)->findOneBy([ 'password' => $loginsession->getPassword() , 'email' => $loginsession->getEmail() ]);
        $json = $serializer->serialize($user, 'json' , ['groups' => 'location:info']);
        $response = new JsonResponse($json, 200, [], true);

        return $response;
    }


}
<file_sep><?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * PriseDeVue
 *
 * @ORM\Table(name="prise_de_vue", indexes={@ORM\Index(name="IDX_3EAEED81B5E42F98", columns={"id_activite_habitat_id"}), @ORM\Index(name="IDX_3EAEED81A74ADF1", columns={"id_habitat_id_prisedevue"})})
 * @ORM\Entity
 */
class PriseDeVue
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @Assert\Unique
     * @Groups("location:info")
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="url", type="string", length=150, nullable=false)
     * @Assert\Image(
     * minWidth = 1300,
     * maxWidth = 1900,
     * minHeight = 900,
     * maxHeight = 1400,
     * allowLandscape = false,
     * allowPortrait = false
     * )
     * @Groups("location:info")
     */
    private $url;

    /**
     * @var \Habitat
     *
     * @ORM\ManyToOne(targetEntity="Habitat")
     * @Groups("location:info")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="id_habitat_id_prisedevue", referencedColumnName="id")
     * })
     */
    private $idHabitatIdPrisedevue;

    /**
     * @var \ActiviteHabitat
     *
     * @ORM\ManyToOne(targetEntity="ActiviteHabitat")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="id_activite_habitat_id", referencedColumnName="id")
     * })
     */
    private $idActiviteHabitat;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getUrl(): ?string
    {
        return $this->url;
    }

    public function setUrl(string $url): self
    {
        $this->url = $url;

        return $this;
    }

    public function getIdHabitatIdPrisedevue(): ?Habitat
    {
        return $this->idHabitatIdPrisedevue;
    }

    public function setIdHabitatIdPrisedevue(?Habitat $idHabitatIdPrisedevue): self
    {
        $this->idHabitatIdPrisedevue = $idHabitatIdPrisedevue;

        return $this;
    }

    public function getIdActiviteHabitat(): ?ActiviteHabitat
    {
        return $this->idActiviteHabitat;
    }

    public function setIdActiviteHabitat(?ActiviteHabitat $idActiviteHabitat): self
    {
        $this->idActiviteHabitat = $idActiviteHabitat;

        return $this;
    }


}
<file_sep><?php

namespace App\Controller;

use App\Entity\Domaine;
use App\Form\DomaineType;
use App\Repository\DomaineRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/domaine")
 */
class DomaineController extends AbstractController
{
    /**
     * @Route("/", name="domaine_index", methods={"GET"})
     */
    public function index(DomaineRepository $domaineRepository): Response
    {
        return $this->render('domaine/index.html.twig', [
            'domaines' => $domaineRepository->findAll(),
        ]);
    }

    /**
     * @Route("/new", name="domaine_new", methods={"GET","POST"})
     */
    public function new(Request $request): Response
    {
        $domaine = new Domaine();
        $form = $this->createForm(DomaineType::class, $domaine);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($domaine);
            $entityManager->flush();

            return $this->redirectToRoute('domaine_index');
        }

        return $this->render('domaine/new.html.twig', [
            'domaine' => $domaine,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="domaine_show", methods={"GET"})
     */
    public function show(Domaine $domaine): Response
    {
        return $this->render('domaine/show.html.twig', [
            'domaine' => $domaine,
        ]);
    }

    /**
     * @Route("/{id}/edit", name="domaine_edit", methods={"GET","POST"})
     */
    public function edit(Request $request, Domaine $domaine): Response
    {
        $form = $this->createForm(DomaineType::class, $domaine);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('domaine_index');
        }

        return $this->render('domaine/edit.html.twig', [
            'domaine' => $domaine,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="domaine_delete", methods={"DELETE"})
     */
    public function delete(Request $request, Domaine $domaine): Response
    {
        if ($this->isCsrfTokenValid('delete'.$domaine->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($domaine);
            $entityManager->flush();
        }

        return $this->redirectToRoute('domaine_index');
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Domaine;
use App\Entity\DispoDomaine;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use App\Form\LocationOccupantType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use App\Form\DispoDomaineType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DomaineCalendrierType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('dispoDomaine', CollectionType::class, [
            'entry_type' => DispoDomaineType::class,
            'entry_options' => ['label' => false],
            'allow_add' => true,
            'allow_delete' => true,
            'prototype'     => true,
            'by_reference' => false,

            ])
        ->add('save', SubmitType::class, [
            'attr' => ['class' => 'stripe-button'],
        ]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Domaine::class,

        ]);
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Calendrier;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use App\Form\CalendarHabitatType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;



class DispoLogementType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('dateDispo', CollectionType::class, [
            'entry_type' => CalendarHabitatType::class,
            'entry_options' => ['label' => false],
            'allow_add' => true,
            'allow_delete' => true,
            'prototype'     => true,
            'by_reference' => false,
            'attr' => ['class' => 'js-datepicker'],


        ])
        ->add('save', SubmitType::class, [
            'attr' => ['class' => 'stripe-button'],
        ]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
        ]);
    }
}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20210619104501 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE newsletter (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(150) NOT NULL, prenom VARCHAR(150) NOT NULL, anniversaire DATE DEFAULT NULL, hebergement_prefere VARCHAR(100) NOT NULL, region VARCHAR(200) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE propriete_habitat ADD CONSTRAINT FK_849F5456B3F033AD FOREIGN KEY (id_habitat_propriete_id) REFERENCES habitat (id)');
        $this->addSql('CREATE INDEX IDX_849F5456B3F033AD ON propriete_habitat (id_habitat_propriete_id)');
        $this->addSql('ALTER TABLE user CHANGE url url VARCHAR(65535) NOT NULL');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('DROP TABLE newsletter');
        $this->addSql('ALTER TABLE propriete_habitat DROP FOREIGN KEY FK_849F5456B3F033AD');
        $this->addSql('DROP INDEX IDX_849F5456B3F033AD ON propriete_habitat');
        $this->addSql('ALTER TABLE user CHANGE url url TEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
    }
}
<file_sep><?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * TypeHabitat
 *
 * @ORM\Table(name="type_habitat")
 * @ORM\Entity
 */
class TypeHabitat
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @Assert\Unique
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     * @Assert\NotBlank
     * @ORM\Column(name="nom", type="string", length=30, nullable=false)
     */
    private $nom;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $description;

    /**
     * @ORM\Column(type="string", length=100)
     * @Assert\Image(
     * minWidth = 1300,
     * maxWidth = 1900,
     * minHeight = 900,
     * maxHeight = 1400,
     * allowLandscape = false,
     * allowPortrait = false
     * )
     */
    private $image;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }
    
    public function __toString() {
        return $this->getId()."-".$this->getNom();
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): self
    {
        $this->description = $description;

        return $this;
    }

    public function getImage(): ?string
    {
        return $this->image;
    }

    public function setImage(string $image): self
    {
        $this->image = $image;

        return $this;
    }

}
<file_sep><?php

namespace App\Entity;

use App\Repository\CalendrierRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=CalendrierRepository::class)
 */
class Calendrier
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="date")
     */
    private $dateDispo;

    /**
     * @ORM\ManyToOne(targetEntity=Habitat::class)
     */
    private $idHabitat;

    /**
     * @ORM\Column(type="string", length=100, nullable=true)
     */
    private $etat;



    public function getId(): ?int
    {
        return $this->id;
    }

    public function getDateDispo(): ?\DateTimeInterface
    {
        return $this->dateDispo;
    }

    public function setDateDispo(\DateTimeInterface $dateDispo): self
    {
        $this->dateDispo = $dateDispo;

        return $this;
    }

    public function getIdHabitat(): ?Habitat
    {
        return $this->idHabitat;
    }

    public function setIdHabitat(?Habitat $idHabitat): self
    {
        $this->idHabitat = $idHabitat;

        return $this;
    }

    public function getEtat(): ?string
    {
        return $this->etat;
    }

    public function setEtat(?string $etat): self
    {
        $this->etat = $etat;

        return $this;
    }



}
<file_sep><?php

namespace App\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ReservationType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('occupant', CollectionType::class, [
            'entry_type' => OccupantType::class,
            'entry_options' => ['label' => false],
        ]);   ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            // Configure your form options here
        ]);
    }
}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20210402110703 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE propriete_habitat DROP FOREIGN KEY FK_849F5456583BB8B6');
        $this->addSql('DROP INDEX IDX_849F5456A74ADF1 ON propriete_habitat');
        $this->addSql('ALTER TABLE propriete_habitat ADD id_habitat_propriete_id INT NOT NULL, DROP id_habitat_id_propriete, CHANGE id_propriete_id id_propriete_id INT NOT NULL, CHANGE valeur_propriete valeur_propriete VARCHAR(120) DEFAULT NULL');
        $this->addSql('ALTER TABLE propriete_habitat ADD CONSTRAINT FK_849F5456B3F033AD FOREIGN KEY (id_habitat_propriete_id) REFERENCES habitat (id)');
        $this->addSql('CREATE INDEX IDX_849F5456B3F033AD ON propriete_habitat (id_habitat_propriete_id)');
        $this->addSql('ALTER TABLE user CHANGE url url VARCHAR(65535) NOT NULL');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE propriete_habitat DROP FOREIGN KEY FK_849F5456B3F033AD');
        $this->addSql('DROP INDEX IDX_849F5456B3F033AD ON propriete_habitat');
        $this->addSql('ALTER TABLE propriete_habitat ADD id_habitat_id_propriete INT DEFAULT NULL, DROP id_habitat_propriete_id, CHANGE id_propriete_id id_propriete_id INT DEFAULT NULL, CHANGE valeur_propriete valeur_propriete VARCHAR(30) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');
        $this->addSql('ALTER TABLE propriete_habitat ADD CONSTRAINT FK_849F5456583BB8B6 FOREIGN KEY (id_habitat_id_propriete) REFERENCES habitat (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
        $this->addSql('CREATE INDEX IDX_849F5456A74ADF1 ON propriete_habitat (id_habitat_id_propriete)');
        $this->addSql('ALTER TABLE user CHANGE url url TEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Location;
use App\Entity\Occupant;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use App\Form\LocationOccupantType;
use App\Form\OccupantType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class LocationOccupantType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('occupants', CollectionType::class, [
            'entry_type' => OccupantType::class,
            'entry_options' => ['label' => false],
            'allow_add' => true,
            'allow_delete' => true,
            'by_reference' => false,


        ])
        ->add('save', SubmitType::class, [
            'attr' => ['class' => 'stripe-button'],
        ]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Location::class,
        ]);
    }
}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20210106180558 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('DROP TABLE propriete_habitat');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE propriete_habitat (id INT AUTO_INCREMENT NOT NULL, id_propriete_id INT DEFAULT NULL, id_habitat_id_propriete INT DEFAULT NULL, valeur_propriete VARCHAR(30) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, INDEX IDX_849F54563B9719DD (id_propriete_id), INDEX IDX_849F5456A74ADF1 (id_habitat_id_propriete), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
        $this->addSql('ALTER TABLE propriete_habitat ADD CONSTRAINT FK_849F54563B9719DD FOREIGN KEY (id_propriete_id) REFERENCES propriete (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
        $this->addSql('ALTER TABLE propriete_habitat ADD CONSTRAINT FK_849F5456583BB8B6 FOREIGN KEY (id_habitat_id_propriete) REFERENCES habitat (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
    }
}
<file_sep><?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;

/**
 * ActiviteHabitat
 *
 * @ORM\Table(name="activite_habitat", indexes={@ORM\Index(name="IDX_7191756DD0165F20", columns={"type_activite_id"})})
 * @ORM\Entity
 */
class ActiviteHabitat
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @Assert\Unique
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var float
     * @ORM\Column(name="distance", type="float", precision=10, scale=0, nullable=false)
     */
    private $distance;

    /**
     * @var \Activite
     *
     * @ORM\ManyToOne(targetEntity="Activite")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="type_activite_id", referencedColumnName="id")
     * })
     */
    private $typeActivite;

    /**
     * @ORM\ManyToOne(targetEntity=Habitat::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $idHabitat;


    /**
     * Constructor
     */
    public function __construct()
    {
        $this->habitat = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getDistance(): ?float
    {
        return $this->distance;
    }

    public function setDistance(float $distance): self
    {
        $this->distance = $distance;

        return $this;
    }


    public function getTypeActivite(): ?Activite
    {
        return $this->typeActivite;
    }

    public function setTypeActivite(?Activite $typeActivite): self
    {
        $this->typeActivite = $typeActivite;

        return $this;
    }

    public function getIdHabitat(): ?Habitat
    {
        return $this->idHabitat;
    }

    public function setIdHabitat(?Habitat $idHabitat): self
    {
        $this->idHabitat = $idHabitat;

        return $this;
    }


}
<file_sep><?php

namespace App\Form;

use App\Entity\Domaine;
use App\Entity\Region ;
use App\Entity\Equipement;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; 



class DomaineType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('nom')
            ->add('description', TextareaType::class)
            ->add('image', FileType::class, array('data_class' => null))
            ->add('arrive', TimeType::class, [
                'input'  => 'datetime',
                'widget' => 'single_text',
            ])
            ->add('depart', TimeType::class, [
                'input' => 'datetime',
                'widget' => 'single_text',
            ])
            ->add('adresse')
            ->add('ville')
            ->add('region', EntityType::class, [
                // looks for choices from this entity
                'class' => Region::class,
            
                // uses the User.username property as the visible option string
                'choice_label' => 'Nom',
            
                // used to render a select box, check boxes or radios
                'multiple' => false,
                'expanded' => false,
            ])
            ->add('equipement', EntityType::class, [
                // looks for choices from this entity
                'class' => Equipement::class,
            
                // uses the User.username property as the visible option string
                'choice_label' => 'Nom',
            
                // used to render a select box, check boxes or radios
                'multiple' => true,
                'expanded' => true,
            ])
            ->add('save', SubmitType::class, [
                'attr' => ['class' => 'btn-edit-profile '],
                'label' => "Enregistrez"

            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Domaine::class,
        ]);
    }
}
<file_sep><?php

namespace App\Controller;

use App\Entity\ActiviteHabitat;
use App\Entity\Habitat;
use App\Form\ActiviteHabitat1Type;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/activite/habitat")
 */
class ActiviteHabitatController extends AbstractController
{
    /**
     * @Route("/{id}", name="activite_habitat_index", methods={"GET"})
     */
    public function index(int $id): Response
    {
        $activiteHabitats = $this->getDoctrine()->getRepository(ActiviteHabitat::class)->findBy(['idHabitat' => $id ]);
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->find($id);
        return $this->render('activite_habitat/index.html.twig', [
            'activite_habitats' => $activiteHabitats,
            'habitat' => $habitat
        ]);
    }

    /**
     * @Route("{id}/new", name="activite_habitat_new", methods={"GET","POST"})
     */
    public function new(int $id , Request $request): Response
    {
        $activiteHabitat = new ActiviteHabitat();
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->find($id);
        $form = $this->createForm(ActiviteHabitat1Type::class, $activiteHabitat);
        $activiteHabitat->setIdHabitat($habitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($activiteHabitat);
            $entityManager->flush();

            return $this->redirectToRoute('/habitat' );
        }

        return $this->render('activite_habitat/new.html.twig', [
            'activite_habitat' => $activiteHabitat,
            'form' => $form->createView(),
            'habitat' => $habitat,
        ]);
    }

    /**
     * @Route("/{idActiviteH}", name="activite_habitat_show", methods={"GET"})
     */
    public function show(ActiviteHabitat $activiteHabitat): Response
    {
        return $this->render('activite_habitat/show.html.twig', [
            'activite_habitat' => $activiteHabitat,
        ]);
    }

    /**
     * @Route("/{idActiviteH}/edit", name="activite_habitat_edit", methods={"GET","POST"})
     */
    public function edit(Request $request, ActiviteHabitat $activiteHabitat): Response
    {
        $form = $this->createForm(ActiviteHabitat1Type::class, $activiteHabitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('activite_habitat_index');
        }

        return $this->render('activite_habitat/edit.html.twig', [
            'activite_habitat' => $activiteHabitat,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{idActiviteH}", name="activite_habitat_delete", methods={"DELETE"})
     */
    public function delete(Request $request, ActiviteHabitat $activiteHabitat): Response
    {
        if ($this->isCsrfTokenValid('delete'.$activiteHabitat->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($activiteHabitat);
            $entityManager->flush();
        }

        return $this->redirectToRoute('activite_habitat_index');
    }
}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\Routing\Annotation\Route;
use App\Repository\NotificationRepository;
use App\Entity\Notification ;
use App\Entity\User;

class NotificationController extends AbstractController
{
    /**
     * @Route("/notification", name="notification")
     */
    public function index(NotificationRepository $notification)
    {
        $user = 4;
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $sql = 'SELECT DISTINCT (notification.id) , notification.titre, notification.contenu , notification.date_publication
        FROM type_habitat,habitat,domaine,notification
        WHERE type_habitat.id = habitat.id_type_habitat_id
        AND domaine.id = habitat.id_domaine_id 
        AND type_habitat.id = notification.id_type_habitat
        AND domaine.id_proprietaire_id  = '.$user.'
        AND notification.id_type_habitat IN (SELECT habitat.id_type_habitat_id
                                           FROM habitat)
        ORDER BY notification.date_publication DESC';
        $em = $this->getDoctrine()->getManager();
        $stmt = $em->getConnection()->prepare($sql);

        $stmt->execute();
        $notification->countBy($user);


        return $this->render('userinterface/alertes.html.twig', [
            'controller_name' => 'NotificationController', 'notifs' => $stmt , 'profil' => $profil
        ]);
    }


    


}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20210101172833 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE domaine_equipement MODIFY id INT NOT NULL');
        $this->addSql('ALTER TABLE domaine_equipement DROP FOREIGN KEY FK_23C6DFED3E47DE39');
        $this->addSql('ALTER TABLE domaine_equipement DROP FOREIGN KEY FK_23C6DFEDDE2F4FD7');
        $this->addSql('DROP INDEX IDX_23C6DFED3E47DE39 ON domaine_equipement');
        $this->addSql('DROP INDEX IDX_23C6DFEDDE2F4FD7 ON domaine_equipement');
        $this->addSql('ALTER TABLE domaine_equipement DROP PRIMARY KEY');
        $this->addSql('ALTER TABLE domaine_equipement ADD domaine_id INT NOT NULL, ADD equipement_id INT NOT NULL, DROP id, DROP id_domaine_equip_id, DROP id_equipement_id');
        $this->addSql('ALTER TABLE domaine_equipement ADD CONSTRAINT FK_23C6DFED4272FC9F FOREIGN KEY (domaine_id) REFERENCES domaine (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE domaine_equipement ADD CONSTRAINT FK_23C6DFED806F0F5C FOREIGN KEY (equipement_id) REFERENCES equipement (id) ON DELETE CASCADE');
        $this->addSql('CREATE INDEX IDX_23C6DFED4272FC9F ON domaine_equipement (domaine_id)');
        $this->addSql('CREATE INDEX IDX_23C6DFED806F0F5C ON domaine_equipement (equipement_id)');
        $this->addSql('ALTER TABLE domaine_equipement ADD PRIMARY KEY (domaine_id, equipement_id)');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE domaine_equipement DROP FOREIGN KEY FK_23C6DFED4272FC9F');
        $this->addSql('ALTER TABLE domaine_equipement DROP FOREIGN KEY FK_23C6DFED806F0F5C');
        $this->addSql('DROP INDEX IDX_23C6DFED4272FC9F ON domaine_equipement');
        $this->addSql('DROP INDEX IDX_23C6DFED806F0F5C ON domaine_equipement');
        $this->addSql('ALTER TABLE domaine_equipement ADD id INT AUTO_INCREMENT NOT NULL, ADD id_domaine_equip_id INT NOT NULL, ADD id_equipement_id INT NOT NULL, DROP domaine_id, DROP equipement_id, DROP PRIMARY KEY, ADD PRIMARY KEY (id)');
        $this->addSql('ALTER TABLE domaine_equipement ADD CONSTRAINT FK_23C6DFED3E47DE39 FOREIGN KEY (id_equipement_id) REFERENCES equipement (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
        $this->addSql('ALTER TABLE domaine_equipement ADD CONSTRAINT FK_23C6DFEDDE2F4FD7 FOREIGN KEY (id_domaine_equip_id) REFERENCES domaine (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
        $this->addSql('CREATE INDEX IDX_23C6DFED3E47DE39 ON domaine_equipement (id_equipement_id)');
        $this->addSql('CREATE INDEX IDX_23C6DFEDDE2F4FD7 ON domaine_equipement (id_domaine_equip_id)');
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Habitat;
use App\Entity\TypeHabitat;
use App\Entity\Region;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class SearchHabitatType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
        ->add('region', EntityType::class, [
            // looks for choices from this entity
            'class' => Region::class,
            'label' => false,
            'help' => 'Make sure to add a valid email',
            'attr' => ['class' => 'champCustomize'],
            // uses the User.username property as the visible option string
            'choice_label' => 'Nom',

        
            'placeholder' => "Destination",

                        
            ])
            ->add('capacite',  ChoiceType::class, [
                'choices' => [
                    '1' => 1,
                    '2' => 2,
                    '3' => 3,
                    '4' => 4,
                    '5' => 5,
                    '6' => 6,
                    '7' => 7,
                    '8' => 8,
                    '9' => 9,
                    '10' => 10,],
                'choice_attr' =>  function($choice, $key, $value) {
                    return ['class' => 'optionNb'];
                 },
                'help' => 'Make sure to add a valid email',
                'placeholder' => 'Personnes',
                'attr' => ['class' => 'champCustomize'],
                'label' => false,

            ])
            ->add('idTypeHabitat', EntityType::class, [
                // looks for choices from this entity
                'class' => TypeHabitat::class,
                'label' => false,
                'help' => 'Make sure to add a valid email',

                // uses the User.username property as the visible option string
                'choice_label' => 'Nom',

            
                'placeholder' => "Type d'Habitat",
                'attr' => [
                    'id' => 'jetestedestrucs', 
                    'class' => 'champCustomize'
                ],
                            
            
                // used to render a select box, check boxes or radios
                'multiple' => false,
                'expanded' => false,
                ])

            ->add('save', SubmitType::class, [
                ]);
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Habitat::class,
        ]);
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Habitat;
use App\Entity\TypeHabitat;
use App\Entity\Activite;
use Symfony\Component\Form\AbstractType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;


class HabitatType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('nom', TextType::class)
            ->add('idTypeHabitat', EntityType::class, [
                // looks for choices from this entity
                'class' => TypeHabitat::class,
            
                // uses the User.username property as the visible option string
                'choice_label' => 'Nom',
            
                // used to render a select box, check boxes or radios
                'multiple' => false,
                'expanded' => false,
            ])
            ->add('nbCouchages', ChoiceType::class, [
                'choices' => [ 
                '1' => 1,
                '2' => 2,
                '3' => 3,
                '4' => 4,
                '5' => 5,
                '6' => 6,
                '7' => 7,
                '8' => 8,
                '9' => 9,
                '10' => 10,
                ]
            ])
            ->add('capacite', ChoiceType::class, [
                'choices' => [
                    '1' => 1,
                    '2' => 2,
                    '3' => 3,
                    '4' => 4,
                    '5' => 5,
                    '6' => 6,
                    '7' => 7,
                    '8' => 8,
                    '9' => 9,
                    '10' => 10,
                ]
            ])
            ->add('prix', MoneyType::class)
            ->add('ville', TextType::class)
            ->add('url',FileType::class, array('data_class' => null))
            ->add('description', TextareaType::class)
            ->add('activiteHabitat', EntityType::class, [
                // looks for choices from this entity
                'class' => Activite::class,
                'mapped' => false ,
                // uses the User.username property as the visible option string
                'choice_label' => 'Nom',
            
                // used to render a select box, check boxes or radios
                'multiple' => true,
                'expanded' => true
            ])
            ->add('save', SubmitType::class, [
                'attr' => ['class' => 'btn-edit-profile '],
                'label' => "Enregistrez"

            ])

        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Habitat::class,
        ]);
    }
}
<file_sep><?php

namespace App\DataFixtures;

use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use App\Entity\TypeHabitat;
use App\Entity\Activite;
use App\Entity\Habitat;
use App\Entity\User;

use Symfony\Component\Validator\Constraints\DateTime;



class AppFixtures extends Fixture
{
    public function load(ObjectManager $manager)
    {

        

    }
}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20210624191943 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE location (id INT AUTO_INCREMENT NOT NULL, id_user_locataire INT DEFAULT NULL, id_habitat_id_location INT DEFAULT NULL, date_reservation DATETIME NOT NULL, dateDebut DATETIME NOT NULL, dateFin DATETIME NOT NULL, statut VARCHAR(25) NOT NULL, appreciation TINYINT(1) DEFAULT NULL, nb_personnes INT NOT NULL, INDEX IDX_5E9E89CB79F37AE5 (id_user_locataire), INDEX IDX_5E9E89CBA74ADF1 (id_habitat_id_location), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE occupant (id INT AUTO_INCREMENT NOT NULL, id_location_id INT NOT NULL, type VARCHAR(200) NOT NULL, INDEX IDX_E7D9DBCA1E5FEC79 (id_location_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE location ADD CONSTRAINT FK_5E9E89CBF9FAC609 FOREIGN KEY (id_user_locataire) REFERENCES user (id)');
        $this->addSql('ALTER TABLE location ADD CONSTRAINT FK_5E9E89CB79273E71 FOREIGN KEY (id_habitat_id_location) REFERENCES habitat (id)');
        $this->addSql('ALTER TABLE occupant ADD CONSTRAINT FK_E7D9DBCA1E5FEC79 FOREIGN KEY (id_location_id) REFERENCES location (id)');
        $this->addSql('ALTER TABLE habitat ADD CONSTRAINT FK_3B37B2E898260155 FOREIGN KEY (region_id) REFERENCES region (id)');
        $this->addSql('CREATE INDEX IDX_3B37B2E898260155 ON habitat (region_id)');
        $this->addSql('ALTER TABLE user CHANGE url url VARCHAR(65535) NOT NULL');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE occupant DROP FOREIGN KEY FK_E7D9DBCA1E5FEC79');
        $this->addSql('DROP TABLE location');
        $this->addSql('DROP TABLE occupant');
        $this->addSql('ALTER TABLE habitat DROP FOREIGN KEY FK_3B37B2E898260155');
        $this->addSql('DROP INDEX IDX_3B37B2E898260155 ON habitat');
        $this->addSql('ALTER TABLE user CHANGE url url MEDIUMTEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
    }
}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\Habitat;
use App\Entity\ActiviteHabitat;
use Symfony\Component\HttpFoundation\Session\Session;
use App\Entity\User;
use App\Entity\PriseDeVue;
use App\Entity\Region;

use App\Entity\Commentaire;
use App\Entity\Domaine;
use App\Entity\TypeHabitat;
use App\Entity\Location;
use App\Form\SearchHabitatType;
use App\Form\ContactOwnerType;

use App\Form\PriseDeVueType;
use App\Form\CommentaireType;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class InternauteController extends AbstractController
{
    /**
     * @Route("/internaute", name="internaute")
     */
    public function index()
    {
        $habitat = new Habitat() ;
        $activite = new ActiviteHabitat();
        $userId = 4 ; 
        $profil = $this->getDoctrine()->getRepository(User::class)->find($userId);
        $repository = $this->getDoctrine()->getRepository(Location::class);
        $historique = $repository->findBy([ 'idUserLocataire' => $userId]
        );
        //$this->denyAccessUnlessGranted('ROLE_USER');
        return $this->render('userinterface/dashboard.html.twig', [
            'habitat' => $habitat , 'activite' => $activite , 'historiques' => $historique, 'profil' => $profil
        ]);
    }

    /**
     * @Route("/home", name="home" , methods={"GET" ,"POST"})
     */
    public function home(Request $request)
    {

        $typehabitat = $this->getDoctrine()->getRepository(TypeHabitat::class)->findAll();
        $habitats = $this->getDoctrine()->getRepository(Domaine::class)->findAll();
        $recherche = new Habitat();
        $region = $this->getDoctrine()->getRepository(Region::class)->findAll();
        $form = $this->createForm(SearchHabitatType::class);

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {

            $recherche = $form->getData();
            // ... do any other work - like sending them an email, etc
            // maybe set a "flash" success message for the user

            return $this->redirectToRoute('listeRecherche', ['habitat' => $recherche->getIdTypeHabitat()->getId() , 'region' => $recherche->getRegion()->getId() , 'capacite' => $recherche->getCapacite()]);

    }
        return $this->render('accueil/index.html.twig', [ 'habitats' => $habitats, 'regions' => $region ,'form' => $form->createView() ,'types' => $typehabitat
        ]);
    }



    /**
     * @Route("/listeDomaines", name="domaine_liste")
     */
    public function listeDomaine() {


        $types = $this->getDoctrine()->getRepository(Region::class)->findAll();

        return $this->render('etablissement/domaines.html.twig', [
            'controller_name' => 'InternauteController' , 'types' => $types
        ]);
    }

    /**
     * @Route("/hebergement", name="hebergements")
     */
    public function listeHebergement() {

        $typehabitat = $this->getDoctrine()->getRepository(TypeHabitat::class)->findAll();

        return $this->render('hebergements/hebergement.html.twig', [
            'controller_name' => 'InternauteController' ,'types' => $typehabitat
        ]);
    }

    /**
     * @Route("/domaines/locations/{id}", name="domaine_details")
     */
    public function listeLocations(int $id) {


        $contact = $this->createForm(ContactOwnerType::class);
        $domaine = $this->getDoctrine()->getRepository(Domaine::class)->find($id);
        $habitat= $this->getDoctrine()->getRepository(Habitat::class)->findby(
            [ 'idDomaine' => $id ]
        );
        if ($contact->isSubmitted() && $contact->isValid()) {
            $expediteur = $contact->get('email')->getData();
            $objet = $contact->get('objet')->getData();
            $contenu = $contact->get('contenu')->getData();
            $destinataire = $user->getEmail();
            $email = (new Email())
            ->from($expediteur)
            ->to('<EMAIL>')
            ->subject($objet)
            ->text($contenu);
            
            $mailer->send($email);

            return $this->redirectToRoute('habitat_domaines' , array('id' => $location->getId()));
        }

        return $this->render('etablissement/locations.html.twig', [
            'controller_name' => 'InternauteController' , 'domaine' => $domaine , 'habitats' => $habitat , 'contact' => $contact->createView() 
        ]);
    }

    /**
     * @Route("/listeHistorique", name="listeHistorique")
     */
    public function listeHistorique()
    {

        $userId = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($userId);
        $repository = $this->getDoctrine()->getRepository(Location::class);
        $user = $this->getDoctrine()->getRepository(User::class)->find($this->getUser()->getId());
        $historique = $repository->findby(['idUserLocataire' => $user , 'statut' => "Valide"]);

        
        return $this->render('userinterface/meslocations.html.twig', [
            'controller_name' => 'InternauteController', 'locations' => $historique   , 'profil' => $profil
        ]);
    }
    
    /**
     * @Route("/locations/comment", name="locations_comments")
     */
    public function locationsCommentaire()
    {

        $userId = 4;
        $profil = $this->getDoctrine()->getRepository(User::class)->find($userId);
        $repository = $this->getDoctrine()->getRepository(Location::class);
        $user = $this->getDoctrine()->getRepository(User::class)->find($userId);
        $historique = $repository->findby(['idUserLocataire' => $user , 'statut' => "Valide"]);

        
        return $this->render('userinterface/comment/listeLocation.html.twig', [
            'controller_name' => 'InternauteController', 'locations' => $historique   , 'profil' => $profil
        ]);
    }

    /**
     * @Route("/listeHistorique/details/{id}", name="listeHistorique_details")
     */
    public function showDetailsReservation(Request $request , int $id){


        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $habitat = $this->getDoctrine()->getRepository(Location::class)->find($id);

        $bien = $habitat->getIdHabitatIdLocation();
        $idBien = $bien->getId();
        $activite = $this->getDoctrine()->getRepository(ActiviteHabitat::class)->findby(['idHabitat' => $idBien]);
        $photo = $this->createForm(PriseDeVueType::class);
        $form = $this->createForm(CommentaireType::class);
        $commentaire = new Commentaire();
        $prisedevue = new PriseDeVue();

        $prisedevue->setIdHabitatIdPrisedevue($bien);


        $form->handleRequest($request);
        $photo->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {

            $commentaire = $form->getData();
            $commentaire->setIdUser($this->getUser());
            $commentaire->setIdHabitatIdCommentaire($bien);
            // ... do any other work - like sending them an email, etc
            // maybe set a "flash" success message for the user
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($commentaire);
            $entityManager->flush();

            return $this->redirectToRoute('listeHistorique_details', ['id' => $id ]);

        }       
        if ($photo->isSubmitted() && $photo->isValid()) {

            $imageurl = $photo->get('url')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('photo_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);
            $prisedevue->setUrl($fichier);
            $prisedevue->setIdHabitatIdPrisedevue($bien);

            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($prisedevue);
            $entityManager->flush();

            return $this->redirectToRoute('listeHistorique_details', ['id' => $id ]);

        }   
        
        return $this->render('userinterface/meslocationsdetails.html.twig', [
            'controller_name' => 'InternauteController', 'profil' => $profil , 'location' => $habitat , 'form' => $form->createView() , 'activites' => $activite , 'photo' => $photo->createView()
        ]);
    }

    /**
     * @Route("/reservationAttente/{id}", name="reservation_attente")
     */
    public function gererReservation(int $id)
    {
        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $reservation = $this->getDoctrine()->getRepository(Location::class)->findBy(['idHabitatIdLocation' => $id , 'statut' => 'En Attente']);

    
        return $this->render('userinterface/reservationHabitat.html.twig', [
            'controller_name' => 'InternauteController', 'locations' => $reservation , 'profil' => $profil]);
        }

    /**
    * @Route("/searchresult", name="searchresult")
    */
    public function searchResult() {



        return $this->render('searchresult.html.twig', [
            'controller_name' => 'InternauteController']);
    }

      
    /**
     * @Route("/valider/{idLocation}", name="valider")
     */
    public function valider(int $idLocation)
    {
        $repository = $this->getDoctrine()->getManager();
        $location = $repository->getRepository(Location::class)->find($idLocation);
        $idhabitat = $location->getIdHabitatIdLocation();
        $location->setStatut('Validé');
        $repository->flush();
        $this->addFlash('success', 'La réservation à bien été validé');
        return $this->redirectToRoute('reservation_attente' , ['id' => $idhabitat]);

    }

    
}
<file_sep><?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;

/**
 * Notification
 *
 * @ORM\Table(name="notification", indexes={@ORM\Index(name="fk_typehabitat", columns={"id_type_habitat"})})
 * @ORM\Entity
 */
class Notification
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     * @Groups("notification:info")
     * @ORM\Column(name="titre", type="string", length=50, nullable=false)
     */
    private $titre;

    /**
     * @var string
     * @Groups("notification:info")
     * @ORM\Column(name="contenu", type="string", length=255, nullable=false)
     */
    private $contenu;

    /**
     * @var \TypeHabitat
     *
     * @ORM\ManyToOne(targetEntity="TypeHabitat")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="id_type_habitat", referencedColumnName="id")
     * })
     */
    private $idTypeHabitat;

    /**
     * @ORM\ManyToMany(targetEntity=Habitat::class, inversedBy="notification")
     */
    private $idHabitat;

    /**
     * @ORM\Column(type="date")
     */
    private $datePublication;

    public function __construct()
    {
        $this->idHabitat = new ArrayCollection();
        $this->datePublication = new \DateTime('now');

    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getTitre(): ?string
    {
        return $this->titre;
    }

    public function setTitre(string $titre): self
    {
        $this->titre = $titre;

        return $this;
    }

    public function getContenu(): ?string
    {
        return $this->contenu;
    }

    public function setContenu(string $contenu): self
    {
        $this->contenu = $contenu;

        return $this;
    }

    public function getIdTypeHabitat(): ?TypeHabitat
    {
        return $this->idTypeHabitat;
    }

    public function setIdTypeHabitat(?TypeHabitat $idTypeHabitat): self
    {
        $this->idTypeHabitat = $idTypeHabitat;

        return $this;
    }

    /**
     * @return Collection|Habitat[]
     */
    public function getIdHabitat(): Collection
    {
        return $this->idHabitat;
    }

    public function addIdHabitat(Habitat $idHabitat): self
    {
        if (!$this->idHabitat->contains($idHabitat)) {
            $this->idHabitat[] = $idHabitat;
        }

        return $this;
    }

    public function removeIdHabitat(Habitat $idHabitat): self
    {
        $this->idHabitat->removeElement($idHabitat);

        return $this;
    }

    public function getDatePublication(): ?\DateTimeInterface
    {
        return $this->datePublication;
    }

    public function setDatePublication(\DateTimeInterface $datePublication): self
    {
        $this->datePublication = $datePublication;

        return $this;
    }


}
<file_sep><?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Braintree
 *
 * @ORM\Table(name="braintree")
 * @ORM\Entity
 */
class Braintree
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="merchant_id", type="string", length=40, nullable=false)
     */
    private $merchantId;

    /**
     * @var string
     *
     * @ORM\Column(name="public_key", type="string", length=30, nullable=false)
     */
    private $publicKey;

    /**
     * @var string
     *
     * @ORM\Column(name="private_key", type="string", length=70, nullable=false)
     */
    private $privateKey;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getMerchantId(): ?string
    {
        return $this->merchantId;
    }

    public function setMerchantId(string $merchantId): self
    {
        $this->merchantId = $merchantId;

        return $this;
    }

    public function getPublicKey(): ?string
    {
        return $this->publicKey;
    }

    public function setPublicKey(string $publicKey): self
    {
        $this->publicKey = $publicKey;

        return $this;
    }

    public function getPrivateKey(): ?string
    {
        return $this->privateKey;
    }

    public function setPrivateKey(string $privateKey): self
    {
        $this->privateKey = $privateKey;

        return $this;
    }


}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20201227091538 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE domaine_equipement (id INT AUTO_INCREMENT NOT NULL, id_domaine_equip_id INT NOT NULL, id_equipement_id INT NOT NULL, INDEX IDX_23C6DFEDDE2F4FD7 (id_domaine_equip_id), INDEX IDX_23C6DFED3E47DE39 (id_equipement_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE domaine_equipement ADD CONSTRAINT FK_23C6DFEDDE2F4FD7 FOREIGN KEY (id_domaine_equip_id) REFERENCES domaine (id)');
        $this->addSql('ALTER TABLE domaine_equipement ADD CONSTRAINT FK_23C6DFED3E47DE39 FOREIGN KEY (id_equipement_id) REFERENCES equipement (id)');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('DROP TABLE domaine_equipement');
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Propriete;
use App\Entity\TypeHabitat;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ProprieteType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('nom', TextType::class)
            ->add('type', ChoiceType::class,  [
                'choices'  => [
                    'Chaîne de caractère' => 'chaine',
                    'Entier' => 'entier',
                    'Décimal' => "decimal",
                ]])
            ->add('obligatoire', CheckboxType::class  , array('required' => false , 'data' => true))
            ->add('idTypeHabitat',EntityType::class, [
                'class' => TypeHabitat::class,
            
                // uses the User.username property as the visible option string
                'choice_label' => 'Nom',
            
                // used to render a select box, check boxes or radios
                'multiple' => false,
                'expanded' => false,
            ])
            ->add('save', SubmitType::class, ['label' => 'Valider'])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Propriete::class,
        ]);
    }
}
<file_sep><?php

namespace App\Entity;

use App\Repository\NewsletterRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=NewsletterRepository::class)
 */
class Newsletter
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=150)
     */
    private $email;

    /**
     * @ORM\Column(type="string", length=150)
     */
    private $prenom;

    /**
     * @ORM\Column(type="date", nullable=true)
     */
    private $anniversaire;

    /**
     * @ORM\ManyToOne(targetEntity=Region::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $region;

    /**
     * @ORM\ManyToOne(targetEntity=TypeHabitat::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $Hebergement;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getEmail(): ?string
    {
        return $this->email;
    }

    public function setEmail(string $email): self
    {
        $this->email = $email;

        return $this;
    }

    public function getPrenom(): ?string
    {
        return $this->prenom;
    }

    public function setPrenom(string $prenom): self
    {
        $this->prenom = $prenom;

        return $this;
    }

    public function getAnniversaire(): ?\DateTimeInterface
    {
        return $this->anniversaire;
    }

    public function setAnniversaire(?\DateTimeInterface $anniversaire): self
    {
        $this->anniversaire = $anniversaire;

        return $this;
    }

    public function getRegion(): ?Region
    {
        return $this->region;
    }

    public function setRegion(?Region $region): self
    {
        $this->region = $region;

        return $this;
    }

    public function getHebergement(): ?TypeHabitat
    {
        return $this->Hebergement;
    }

    public function setHebergement(?TypeHabitat $Hebergement): self
    {
        $this->Hebergement = $Hebergement;

        return $this;
    }

}
<file_sep><?php

namespace App\Entity;

use App\Repository\ProprieteHabitatRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=ProprieteHabitatRepository::class)
 */
class ProprieteHabitat
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=Propriete::class)
     * @ORM\JoinColumn(nullable=false,onDelete="CASCADE")
     */
    private $idPropriete;

    /**
     * @ORM\ManyToOne(targetEntity=Habitat::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $IdHabitatPropriete;

    /**
     * @ORM\Column(type="string", length=120, nullable=true)
     */
    private $valeurPropriete;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getIdPropriete(): ?Propriete
    {
        return $this->idPropriete;
    }

    public function setIdPropriete(?Propriete $idPropriete): self
    {
        $this->idPropriete = $idPropriete;

        return $this;
    }

    public function getIdHabitatPropriete(): ?Habitat
    {
        return $this->IdHabitatPropriete;
    }

    public function setIdHabitatPropriete(?Habitat $IdHabitatPropriete): self
    {
        $this->IdHabitatPropriete = $IdHabitatPropriete;

        return $this;
    }

    public function getValeurPropriete(): ?string
    {
        return $this->valeurPropriete;
    }

    public function setValeurPropriete(?string $valeurPropriete): self
    {
        $this->valeurPropriete = $valeurPropriete;

        return $this;
    }
}
<file_sep><?php

namespace App\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;

/**
 * Activite
 *
 * @ORM\Table(name="activite")
 * @ORM\Entity
 */
class Activite
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="nom", type="string", length=30, nullable=false)
     */
    private $nom;

    /**
     * 
     * @ORM\Column(type="string", length=150)
     */
    private $image;

    /**
     * @ORM\Column(type="float")
     */
    private $prix;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $adresse;

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    private $description;

    /**
     * @ORM\ManyToOne(targetEntity=Domaine::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $idDomaine;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }

    public function __toString(){
        // to show the name of the Category in the select
        return $this->nom;
        // to show the id of the Category in the select
        // return $this->id;
    }

    public function getImage(): ?string
    {
        return $this->image;
    }

    public function setImage(string $image): self
    {
        $this->image = $image;

        return $this;
    }

    public function getPrix(): ?float
    {
        return $this->prix;
    }

    public function setPrix(float $prix): self
    {
        $this->prix = $prix;

        return $this;
    }

    public function getAdresse(): ?string
    {
        return $this->adresse;
    }

    public function setAdresse(string $adresse): self
    {
        $this->adresse = $adresse;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): self
    {
        $this->description = $description;

        return $this;
    }

    public function getIdDomaine(): ?Domaine
    {
        return $this->idDomaine;
    }

    public function setIdDomaine(?Domaine $idDomaine): self
    {
        $this->idDomaine = $idDomaine;

        return $this;
    }


}
<file_sep><?php

namespace App\Form;

use App\Entity\Newsletter;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\RadioType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use App\Entity\TypeHabitat;
use App\Entity\Region;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;

class NewsletterType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('email',EmailType::class, [
                'help' => "Votre adresse mail devrat être vérifier",
                
                'attr' => array(
                    'placeholder' => '<EMAIL>',

                )
            ])
            ->add('prenom')
            ->add('anniversaire' , DateType::class, [
                'widget' => 'single_text',
                'attr' => ['class' => 'js-datepicker'],
                'html5' => false,
            ])
            ->add('hebergement', EntityType::class, [
                // looks for choices from this entity
                'class' => TypeHabitat::class,
                'label' => false,
                'help' => 'Make sure to add a valid email',

                // uses the User.username property as the visible option string
                'choice_label' => 'Nom',

            
                'placeholder' => "Choisissez une valeur",
                'attr' => [
                    'id' => 'jetestedestrucs', 
                ],
                            
            
                // used to render a select box, check boxes or radios
                'multiple' => false,
                'expanded' => false,
                ])
            ->add('region', EntityType::class, [
                // looks for choices from this entity
                'class' => Region::class,
                'label' => false,
                'help' => 'Make sure to add a valid email',
                // uses the User.username property as the visible option string
                'choice_label' => 'Nom',
    
            
                'placeholder' => "Choisissez une valeur",
    
                            
                ])
            ->add('save', SubmitType::class, [
                'attr' => ['class' => 'bouton-violet'],

            ]);
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Newsletter::class,
        ]);
    }
}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use App\Entity\Location;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\HttpFoundation\JsonResponse;

class StripeController extends AbstractController
{
    /**
     * @Route("/stripe", name="stripe")
     */
    public function index(Request $request): Response
    {

        var_dump($request->request->all());
        return $this->render('stripe/index.html.twig', [
            'controller_name' => 'StripeController',
        ]);
    }




}
<file_sep><?php

namespace App\Entity;

use App\Repository\DomaineRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=DomaineRepository::class)
 */
class Domaine
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $nom;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $description;

    /**
     * @ORM\ManyToOne(targetEntity=User::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $idProprietaire;

    /**
     * )
     * @ORM\Column(type="string", length=45)
     */
    private $image;

    /**
     * @ORM\Column(type="time")
     */
    private $arrive;

    /**
     * @ORM\Column(type="time")
     */
    private $depart;

    /**
     * @ORM\Column(type="string", length=50)
     */
    private $adresse;

    /**
     * @ORM\Column(type="string", length=45)
     */
    private $ville;

    /**
     * @ORM\Column(type="string", length=60)
     */
    private $pays;

    /**
     * @ORM\ManyToMany(targetEntity=Equipement::class)
     * @Groups("location:info")
     */
    private $equipement;

    /**
     * @ORM\ManyToOne(targetEntity=Region::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $region;



    public function __construct()
    {
        $this->equipement = new ArrayCollection();
        $this->pays = "France" ;
        $this->calendrierDomaines = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(string $description): self
    {
        $this->description = $description;

        return $this;
    }

    public function getIdProprietaire(): ?User
    {
        return $this->idProprietaire;
    }

    public function setIdProprietaire(?User $idProprietaire): self
    {
        $this->idProprietaire = $idProprietaire;

        return $this;
    }

    public function getImage(): ?string
    {
        return $this->image;
    }

    public function setImage(string $image): self
    {
        $this->image = $image;

        return $this;
    }

    public function getArrive(): ?\DateTimeInterface
    {
        return $this->arrive;
    }

    public function setArrive(\DateTimeInterface $arrive): self
    {
        $this->arrive = $arrive;

        return $this;
    }

    public function getDepart(): ?\DateTimeInterface
    {
        return $this->depart;
    }

    public function setDepart(\DateTimeInterface $depart): self
    {
        $this->depart = $depart;

        return $this;
    }

    public function getAdresse(): ?string
    {
        return $this->adresse;
    }

    public function setAdresse(string $adresse): self
    {
        $this->adresse = $adresse;

        return $this;
    }

    public function getVille(): ?string
    {
        return $this->ville;
    }

    public function setVille(string $ville): self
    {
        $this->ville = $ville;

        return $this;
    }

    public function getPays(): ?string
    {
        return $this->pays;
    }

    public function setPays(string $pays): self
    {
        $this->pays = $pays;

        return $this;
    }

    /**
     * @return Collection|Equipement[]
     */
    public function getEquipement(): Collection
    {
        return $this->equipement;
    }

    public function addEquipement(Equipement $equipement): self
    {
        if (!$this->equipement->contains($equipement)) {
            $this->equipement[] = $equipement;
        }

        return $this;
    }

    public function removeEquipement(Equipement $equipement): self
    {
        $this->equipement->removeElement($equipement);

        return $this;
    }

    public function getRegion(): ?Region
    {
        return $this->region;
    }

    public function setRegion(?Region $region): self
    {
        $this->region = $region;

        return $this;
    }
        /**
     * @return Collection|DispoDomaine[]
     */
    public function getDispoDomaine(): Collection
    {
        return $this->calendrierDomaines;
    }

    public function addDispoDomaine(DispoDomaine $dispo): self
    {
        if (!$this->calendrierDomaines->contains($dispo)) {
            $this->calendrierDomaines[] = $dispo;
            $dispo->setIdDomaine($this);
        }

        return $this;
    }

    public function removeDispoDomaine(DispoDomaine $dispo): self
    {
        if ($this->calendrierDomaines->removeElement($dispo)) {
            // set the owning side to null (unless already changed)
            if ($dispo->getIdDomaine() === $this) {
                $dispo->setIdDomaine(null);
            }
        }

        return $this;
    }
}
<file_sep><?php

namespace App\Entity;

use App\Repository\EquipementRepository;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=EquipementRepository::class)
 */
class Equipement
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=45)
     * @Assert\Unique
     * @Groups("location:info")
     */
    private $nom;

    /**
     * @ORM\Column(type="string", length=100)
     * @Assert\Image(
     * maxWidth = 512,
     * maxHeight = 512,
     * allowLandscape = false,
     * allowPortrait = false
     * )
     */
    private $icon;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }

    public function getIcon(): ?string
    {
        return $this->icon;
    }

    public function setIcon(string $icon): self
    {
        $this->icon = $icon;

        return $this;
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Location;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Validator\Constraints\DateTime ;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class Location1Type extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('dateDebut', DateType::class, [
            'widget' => 'single_text',

            // prevents rendering it as type="date", to avoid HTML5 date pickers
            'html5' => false,
        
            // adds a class that can be selected in JavaScript
            'attr' => ['class' => 'js-datepicker'],
        ])
            ->add('dateFin',  DateTimeType::class, [
                'widget' => 'single_text',
    
                // prevents rendering it as type="date", to avoid HTML5 date pickers
                'html5' => false,
            
                // adds a class that can be selected in JavaScript
                'attr' => ['class' => 'js-datepicker'],
            ])
            ->add('nbpersonnes',  ChoiceType::class, [
                'choices'  => [
                    '1 personne' => 1,
                    '2 personnes' => 2,
                    '3 personnes' => 3,
                    '4 personnes' => 4
                ],
            ])
            ->add('reserver',  SubmitType::class) ;

                
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Location::class,
        ]);
    }
}
<file_sep><?php

namespace App\Entity;

use App\Repository\OccupantRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=OccupantRepository::class)
 */
class Occupant
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=200)
     */
    private $type;

    /**
     * @ORM\ManyToOne(targetEntity=Location::class, inversedBy="occupants")
     * @ORM\JoinColumn(nullable=false)
     */
    private $idLocation;


    public function getId(): ?int
    {
        return $this->id;
    }

    public function getType(): ?string
    {
        return $this->type;
    }

    public function setType(string $type): self
    {
        $this->type = $type;

        return $this;
    }

    public function getIdLocation(): ?Location
    {
        return $this->idLocation;
    }

    public function setIdLocation(?Location $idLocation): self
    {
        $this->idLocation = $idLocation;

        return $this;
    }

}
<file_sep><?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Constraints\RangeValidator;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Serializer\Annotation\Groups;

use Doctrine\ORM\Mapping as ORM;

/**
 * Location
 * @ORM\Table(name="location", indexes={@ORM\Index(name="IDX_5E9E89CB79F37AE5", columns={"id_user_locataire"}), @ORM\Index(name="IDX_5E9E89CBA74ADF1", columns={"id_habitat_id_location"})})
 * @ORM\Entity
 */
class Location
{
    /**
     * @var int
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var \DateTime
     * @Groups("location:info")
     * @Groups("appitat:info")
     * @ORM\Column(name="date_reservation", type="datetime", nullable=false)
     */
    private $dateReservation;

    /**
     * @Assert\GreaterThan("+5 hours")
     * @Groups("location:info")
     * @Groups("appitat:info")
     * @var \DateTime
     * @ORM\Column(name="dateDebut", type="datetime", nullable=false)
     */
    private $datedebut;

    /**
    * @Assert\GreaterThan("today")
     * @Groups("location:info")
     * @var \DateTime
     * @ORM\Column(name="dateFin", type="datetime", nullable=false)
     */
    private $datefin;

    /**
     * @var string
     * @ORM\Column(name="statut", type="string", length=25, nullable=false)
     */
    private $statut;

    /**
     * @var \User
     * @ORM\ManyToOne(targetEntity="User")
     * @Groups("location:info")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="id_user_locataire", referencedColumnName="id")
     * })
     */
    private $idUserLocataire;

    /**
     * @var \Habitat
     * @ORM\ManyToOne(targetEntity="Habitat")
     * @Groups("location:info")
     * @ORM\JoinColumns({
     * @ORM\JoinColumn(name="id_habitat_id_location", referencedColumnName="id")
     * })
     */
    private $idHabitatIdLocation;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     */
    private $appreciation;

    /**
     * @ORM\Column(type="integer")
     */
    private $nbPersonnes;

    /**
     * @ORM\OneToMany(targetEntity=Occupant::class, mappedBy="idLocation", orphanRemoval=true)
     */
    private $occupants;

    /**
    * Constructor
    */
    public function __construct()
    {
        $this->dateReservation = new \DateTime('now');
        $this->statut = "En Attente";
        $this->occupants = new ArrayCollection();

    }
     

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getDateReservation(): ?\DateTimeInterface
    {
        return $this->dateReservation;
    }

    public function setDateReservation(\DateTimeInterface $dateReservation): self
    {
        $this->dateReservation = $dateReservation;

        return $this;
    }

    public function getDatedebut(): ?\DateTimeInterface
    {
        return $this->datedebut;
    }

    public function setDatedebut($datedebut): self
    {
        $this->datedebut = $datedebut;

        return $this;
    }

    public function getDatefin(): ?\DateTimeInterface
    {
        return $this->datefin;
    }

    public function setDatefin($datefin): self
    {
        $this->datefin = $datefin;

        return $this;
    }

    public function getStatut(): ?string
    {
        return $this->statut;
    }

    public function setStatut(string $statut): self
    {
        $this->statut = $statut;

        return $this;
    }

    public function getIdUserLocataire(): ?User
    {
        return $this->idUserLocataire;
    }

    public function setIdUserLocataire(?User $idUserLocataire): self
    {
        $this->idUserLocataire = $idUserLocataire;

        return $this;
    }

    public function getIdHabitatIdLocation(): ?Habitat
    {
        return $this->idHabitatIdLocation;
    }

    public function setIdHabitatIdLocation(?Habitat $idHabitatIdLocation): self
    {
        $this->idHabitatIdLocation = $idHabitatIdLocation;

        return $this;
    }

    public function getAppreciation(): ?bool
    {
        return $this->appreciation;
    }

    public function setAppreciation(?bool $appreciation): self
    {
        $this->appreciation = $appreciation;

        return $this;
    }

    public function getNbPersonnes(): ?int
    {
        return $this->nbPersonnes;
    }

    public function setNbPersonnes(int $nbPersonnes): self
    {
        $this->nbPersonnes = $nbPersonnes;

        return $this;
    }

    /**
     * @return Collection|Occupant[]
     */
    public function getOccupants(): Collection
    {
        return $this->occupants;
    }

    public function addOccupant(Occupant $occupant): self
    {
        if (!$this->occupants->contains($occupant)) {
            $this->occupants[] = $occupant;
            $occupant->setIdLocation($this);
        }

        return $this;
    }

    public function removeOccupant(Occupant $occupant): self
    {
        if ($this->occupants->removeElement($occupant)) {
            // set the owning side to null (unless already changed)
            if ($occupant->getIdLocation() === $this) {
                $occupant->setIdLocation(null);
            }
        }

        return $this;
    }




}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use App\Entity\Domaine ;
use App\Entity\ActiviteHabitat;
use App\Entity\Activite;
use App\Entity\Habitat;
use App\Entity\Location;
use App\Entity\Commentaire;
use App\Entity\Calendrier;
use App\Form\Location1Type;
use App\Form\ContactOwnerType;
use App\Entity\PriseDeVue ;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\HttpFoundation\Session\Session;

use Symfony\Component\Routing\Annotation\Route;

class RentController extends AbstractController
{
    /**
     * @Route("/rent", name="rent")
     */
    public function index(): Response
    {
        return $this->render('rent/index.html.twig', [
            'controller_name' => 'RentController',
        ]);
    }


    /**
     * @Route("/domaines/habitat/{id}", name="habitat_domaines")
     */
    public function voirHabitat(Request $request , int $id, MailerInterface $mailer) {

        $habitat= $this->getDoctrine()->getRepository(Habitat::class)->find($id);
        $domaine= $this->getDoctrine()->getRepository(Domaine::class)->findOneby(
            [ 'id' => $habitat->getIdDomaine() ]
        );
        $commentaire = $this->getDoctrine()->getRepository(Commentaire::class)->findby(
            [ 'idHabitatIdCommentaire' => $habitat->getId() ]
        );
        $photos = $this->getDoctrine()->getRepository(PriseDeVue::class)->findby(
            [ 'idHabitatIdPrisedevue' => $habitat->getId() ]
        );

        $location = new Location();
        $user = $this->getUser();
        $location->setIdUserLocataire($user);
        $location->setIdHabitatIdLocation($habitat);
        $activite = $this->getDoctrine()->getRepository(Activite::class)->findby(['idDomaine' => $id]);
        $formReservation = $this->createForm(Location1Type::class, $location);
        $dispoHabitat = $this->getDoctrine()->getRepository(Calendrier::class)->findBy([ 'idHabitat' => $id , 'etat' => 'D']);
        $dateOccupe = $this->getDoctrine()->getRepository(Calendrier::class)->findBy([ 'idHabitat' => $id , 'etat' => 'O']);


        $formReservation->handleRequest($request);

        if ($formReservation->isSubmitted() && $formReservation->isValid()) {
            $depart = $formReservation->get('dateDebut')->getData();
            $arrivee = $formReservation->get('dateFin')->getData();
            $occupant = $formReservation->get('nbpersonnes')->getData();
            $this->get('session')->set('depart', $depart);
            $this->get('session')->set('arrivee', $arrivee);
            $this->get('session')->set('occupant', $occupant);
            
            return $this->redirectToRoute('reserver' , array('id' => $id ));

        
            // ... further modify the response or return it directly
        

        }





        return $this->render('etablissement/habitat.html.twig', [
            'controller_name' => 'InternauteController' ,'comments' => $commentaire , 'rent' => $formReservation->createView() ,'activites' => $activite , 'habitats' => $habitat , 'domaines' => $domaine , 'photos' => $photos , 'datesHabitats' => $dispoHabitat , 'dateOccupes' => $dateOccupe ,
        ]);
    }

    /**
    * @Route("habitatactivite/{id}", name="habitat_activite")
    */
    public function showActivite(int $id) {


        $activite = $this->getDoctrine()->getRepository(ActiviteHabitat::class)->findOneBy(['typeActivite' => $id ]);
        $habitat = $activite->getIdHabitat();

        $commentaire = $this->getDoctrine()->getRepository(Commentaire::class)->findby(
            [ 'idActiviteHabitat' => $activite->getId() ]
        );
        $photos = $this->getDoctrine()->getRepository(PriseDeVue::class)->findby(
            [ 'idActiviteHabitat' => $activite->getId() ]
        );
        return $this->render('etablissement/activiteprhabitat.html.twig', [
            'controller_name' => 'InternauteController' , 'habitat' => $habitat ,'activite' => $activite , 'photos' => $photos , 'comments' => $commentaire 
        ]);
    }

}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20210706183046 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE calendrier (id INT AUTO_INCREMENT NOT NULL, date_dispo DATE NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE habitat ADD CONSTRAINT FK_3B37B2E898260155 FOREIGN KEY (region_id) REFERENCES region (id)');
        $this->addSql('CREATE INDEX IDX_3B37B2E898260155 ON habitat (region_id)');
        $this->addSql('ALTER TABLE user CHANGE url url VARCHAR(65535) NOT NULL');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('DROP TABLE calendrier');
        $this->addSql('ALTER TABLE habitat DROP FOREIGN KEY FK_3B37B2E898260155');
        $this->addSql('DROP INDEX IDX_3B37B2E898260155 ON habitat');
        $this->addSql('ALTER TABLE user CHANGE url url MEDIUMTEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
    }
}
<file_sep><?php

namespace App\Form;


use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class InscriptionUserType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
        ->add('password', RepeatedType::class, array(
            'type' => PasswordType::class,
            'first_options'  => array('label' => 'Mot de Passe'),
            'second_options' => array('label' => 'Confirmez votre Mot de Passe'),
        ))
        ->add('email', EmailType::class , ['label' => 'Adresse E-Mail'])
        ->add('nom', TextType::class, ['label' => 'Nom'])
        ->add('prenom', TextType::class,['label' => 'Prénom'])
        ->add('adresse', TextType::class, ['label' => 'Adresse'])
        ->add('ville', TextType::class, ['label' => 'Ville'])
        ->add('cp', TextType::class, ['label' => 'Code Postal'])
        ->add('dateNaissance', DateType::class, [
            'widget' => 'single_text',
            'format' => 'dd/MM/yyyy',
            // prevents rendering it as type="date", to avoid HTML5 date pickers
            'html5' => false,
            'attr' => ['class' => 'calendate']])

            // adds a class that can be selected in JavaScript)
        ->add('genre', ChoiceType::class, [
            'choices'  => [
                'Homme' => "Homme",
                'Femme' => "Femme",

            ],
            'multiple' => false,
            'expanded' => true])
        ->add('telephone')
        ->add('biographie')
        ->add("Validez", SubmitType::class, [
            'attr' => ['class' => 'btn btn-primary m-5 stripe-button'],
        ]);        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            // Configure your form options here
        ]);
    }
}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20201226214934 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE habitat ADD id_domaine_id INT NOT NULL');
        $this->addSql('ALTER TABLE habitat ADD CONSTRAINT FK_3B37B2E8E7F87C48 FOREIGN KEY (id_domaine_id) REFERENCES domaine (id)');
        $this->addSql('CREATE INDEX IDX_3B37B2E8E7F87C48 ON habitat (id_domaine_id)');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE habitat DROP FOREIGN KEY FK_3B37B2E8E7F87C48');
        $this->addSql('DROP INDEX IDX_3B37B2E8E7F87C48 ON habitat');
        $this->addSql('ALTER TABLE habitat DROP id_domaine_id');
    }
}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20201227090857 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE domaine_equipement (domaine_id INT NOT NULL, equipement_id INT NOT NULL, INDEX IDX_23C6DFED4272FC9F (domaine_id), INDEX IDX_23C6DFED806F0F5C (equipement_id), PRIMARY KEY(domaine_id, equipement_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE equipement (id INT AUTO_INCREMENT NOT NULL, nom VARCHAR(45) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE domaine_equipement ADD CONSTRAINT FK_23C6DFED4272FC9F FOREIGN KEY (domaine_id) REFERENCES domaine (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE domaine_equipement ADD CONSTRAINT FK_23C6DFED806F0F5C FOREIGN KEY (equipement_id) REFERENCES equipement (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE domaine ADD arrive TIME NOT NULL, ADD depart TIME NOT NULL');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE domaine_equipement DROP FOREIGN KEY FK_23C6DFED806F0F5C');
        $this->addSql('DROP TABLE domaine_equipement');
        $this->addSql('DROP TABLE equipement');
        $this->addSql('ALTER TABLE domaine DROP arrive, DROP depart');
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Propriete;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FileType;

use Symfony\Component\OptionsResolver\OptionsResolver;

class Propriete1Type extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('nom')
            ->add('type', ChoiceType::class,  [
                'choices'  => [
                    'Chaîne de caractère' => 'chaine',
                    'Entier' => 'entier',
                    'Décimal' => "decimal",
                ]])            ->add('obligatoire')
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Propriete::class,
        ]);
    }
}
<file_sep><?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * Commentaire
 *
 * @ORM\Table(name="commentaire", uniqueConstraints={@ORM\UniqueConstraint(name="UNIQ_67F068BC79F37AE5", columns={"id_user_id"})}, indexes={@ORM\Index(name="IDX_67F068BCA74ADF1", columns={"id_habitat_id_commentaire"})})
 * @ORM\Entity
 */
class Commentaire
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     * @Groups("location:info")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="contenu", type="text", length=0, nullable=false)
     * @Groups("location:info")
     */
    private $contenu;

    /**
     * @var \User
     *
     * @ORM\ManyToOne(targetEntity="User")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="id_user_id", referencedColumnName="id")
     * })
     * @Groups("location:info")
     */
    private $idUser;

    /**
     * @var \Habitat
     *
     * @ORM\ManyToOne(targetEntity="Habitat")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="id_habitat_id_commentaire", referencedColumnName="id")
     * })
     */
    private $idHabitatIdCommentaire;

    /**
     * @ORM\Column(type="string", length=45)
     * @Groups("location:info")
     */
    private $titre;

    /**
     * @ORM\ManyToOne(targetEntity=ActiviteHabitat::class)
     * @ORM\JoinColumn(nullable=true)
     */
    private $idActiviteHabitat;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getContenu(): ?string
    {
        return $this->contenu;
    }

    public function setContenu(string $contenu): self
    {
        $this->contenu = $contenu;

        return $this;
    }

    public function getIdUser(): ?User
    {
        return $this->idUser;
    }

    public function setIdUser(?User $idUser): self
    {
        $this->idUser = $idUser;

        return $this;
    }

    public function getIdHabitatIdCommentaire(): ?Habitat
    {
        return $this->idHabitatIdCommentaire;
    }

    public function setIdHabitatIdCommentaire(?Habitat $idHabitatIdCommentaire): self
    {
        $this->idHabitatIdCommentaire = $idHabitatIdCommentaire;

        return $this;
    }

    public function getTitre(): ?string
    {
        return $this->titre;
    }

    public function setTitre(string $titre): self
    {
        $this->titre = $titre;

        return $this;
    }

    public function getIdActiviteHabitat(): ?ActiviteHabitat
    {
        return $this->idActiviteHabitat;
    }

    public function setIdActiviteHabitat(?ActiviteHabitat $idActiviteHabitat): self
    {
        $this->idActiviteHabitat = $idActiviteHabitat;

        return $this;
    }


}
<file_sep><?php

namespace App\Repository;

use App\Entity\Habitat;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Component\Validator\Constraints\NotEqualTo;
use Symfony\Component\Validator\Constraints\NotEqualToValidator;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @method Habitat|null find($id, $lockMode = null, $lockVersion = null)
 * @method Habitat|null findOneBy(array $criteria, array $orderBy = null)
 * @method Habitat[]    findAll()
 * @method Habitat[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class HabitatRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Habitat::class);
    }

    /**
    * @return Habitat[] Returns an array of Habitat objects
    */
    public function findByProprietaire($user)
    {
        return $this->createQueryBuilder('h')
            ->andWhere('h.id_proprietaire !== :user')
            ->setParameter($user , false)
            ->orderBy('h.datePublication', 'ASC')
            ->setMaxResults(20)
            ->getQuery()
            ->getResult()
        ;
    }

    public function countId()
    {
        return $this->createQueryBuilder('id')
 
                        ->select('COUNT(id)')
 
                        ->getQuery()
 
                        ->getSingleScalarResult();
    }
    /*
    public function findOneBySomeField($value): ?Habitat
    {
        return $this->createQueryBuilder('h')
            ->andWhere('h.exampleField = :val')
            ->setParameter('val', $value)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
    */}<file_sep><?php

namespace App\Controller;

use App\Entity\Habitat;
use App\Form\HabitatType;
use App\Entity\User;
use App\Repository\HabitatRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
 */
/**
 * @Route("/habitat")
 * @IsGranted("ROLE_USER") 
 */
class HabitatController extends AbstractController
{
    /**
     * @Route("/", name="habitat_index", methods={"GET"})
     */
    public function index(): Response
    {
        $user = $this->getUser();
        $habitats = $this->getDoctrine()
            ->getRepository(Habitat::class)
            ->findBy(['proprietaire' => $user]);

        return $this->render('habitat/index.html.twig', [
            'habitats' => $habitats,
        ]);
    }

    /**
     * @Route("/new", name="habitat_new", methods={"GET","POST"})
     */
    public function new(Request $request): Response
    {
        $habitat = new Habitat();
        $user = $this->getUser();
        $habitat->setProprietaire($user);
        $form = $this->createForm(HabitatType::class, $habitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($habitat);
            $entityManager->flush();

            return $this->redirectToRoute('habitat_index');
        }

        return $this->render('habitat/new.html.twig', [
            'habitat' => $habitat,
            'form' => $form->createView(),

        ]);
    }

    /**
     * @Route("/{id}", name="habitat_show", methods={"GET"})
     */
    public function show(Habitat $habitat): Response
    {
        return $this->render('habitat/show.html.twig', [
            'habitat' => $habitat,
        ]);
    }

    /**
     * @Route("/{id}/edit", name="habitat_edit", methods={"GET","POST"})
     */
    public function edit(Request $request, Habitat $habitat): Response
    {
        $form = $this->createForm(HabitatType::class, $habitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('habitat_index');
        }

        return $this->render('habitat/edit.html.twig', [
            'habitat' => $habitat,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="habitat_delete", methods={"DELETE"})
     */
    public function delete(Request $request, Habitat $habitat): Response
    {
        if ($this->isCsrfTokenValid('delete'.$habitat->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($habitat);
            $entityManager->flush();
        }

        return $this->redirectToRoute('habitat_index');
    }
}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\Habitat;
use App\Entity\TypeHabitat;
use App\Entity\Activite;
use App\Entity\Notification ;
use App\Entity\User;
use App\Form\TypeHabitatType;
use App\Form\ProprieteType;
use App\Form\Activite1Type;
use App\Entity\Commentaire;
use App\Entity\ProprieteHabitat ;
use App\Form\Propriete1Type;
use App\Entity\Propriete;
use App\Entity\Location;
use Symfony\Component\HttpFoundation\Request;
use App\Repository\LocationRepository;
use App\Repository\HabitatRepository;
use App\Repository\TypeHabitatRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use App\Repository\ProprieteRepository;
use App\Repository\ActiviteRepository;
use App\Repository\UserRepository;
use App\Repository\PriseDeVueRepository;
use App\Repository\CommentaireRepository;


/**
 * @Route("/gerant")
 */
class GerantController extends AbstractController
{
    /**
     * @Route("/dashboard", name="dashboard")
     */
    public function index(): Response
    {
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->findAll();
        $proprietes = $this->getDoctrine()->getRepository(Propriete::class)->findAll() ;
        $comments = $this->getDoctrine()->getRepository(Commentaire::class)->findAll();
        $location = $this->getDoctrine()->getRepository(Location::class);
        $repoUser =  $this->getDoctrine()->getRepository(User::class);
        $repoBien = $this->getDoctrine()->getRepository(Habitat::class);
        $user = $repoUser->createQueryBuilder('u')
        // Filter by some parameter if you want
        // ->where('a.published = 1')
        ->select('count(u.id)')
        ->getQuery()
        ->getSingleScalarResult();
        $bien = $repoBien->createQueryBuilder('b')
        // Filter by some parameter if you want
        // ->where('a.published = 1')
        ->select('count(b.id)')
        ->getQuery()
        ->getSingleScalarResult();
        $loc = $location->createQueryBuilder('l')
        // Filter by some parameter if you want
        ->select('count(l.id)')
        ->getQuery()
        ->getSingleScalarResult();



        return $this->render('backoff.html.twig', [
            'controller_name' => 'GerantController', 'locations' => $loc , 'habitats' => $habitat , 'proprietes' => $proprietes , 'comments' => $comments , 'users' => $user , 'biens' => $bien
        ]);
    }

    /**
     * @Route("/habitat", name="habitat")
     */
    public function habitat(HabitatRepository $habitatRepository): Response
    {
        return $this->render('habitat_backoff.html.twig', [
            'controller_name' => 'GerantController', 'habitats' => $habitatRepository->findAll()
        ]);
    }   
    
    /**
     * @Route("/typeActivites", name="typeActivites", methods={"GET"})
     */
    public function typesActivites(ActiviteRepository $activiteRepository): Response
    {
        return $this->render('typeActivite.html.twig', [
            'controller_name' => 'GerantController', 'typeActivites' => $activiteRepository->findAll()
        ]);
    }
    /**
     * @Route("/proprietes", name="proprietes" , methods={"DELETE"})
     */
    public function proprietes(ProprieteRepository $proprieteRepository): Response
    {
        return $this->render('proprietes_backoff.html.twig', [
            'controller_name' => 'GerantController', 'proprietes' => $proprieteRepository->findAll()
        ]);
    }
    /**
     * @Route("/proprietes/add", name="proprietes/add")
     */
    public function addProprietes(Request $request): Response
    {

        $propriete = new Propriete();
        $notification = new Notification();
        $form = $this->createForm(ProprieteType::class, $propriete);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {

            $form->getData();
            
            $nomParam = $form->get('nom')->getData();
            $habitatType = $form->get('idTypeHabitat')->getData()->getNom();
            $type = $form->get('type')->getData();
            $obligatoire = $form->get('obligatoire')->getData();
            if ($obligatoire == true) {
                $obligatoire = "oui" ;
            }
            else {
                $obligatoire = "non" ;
            }
            $entryData = array(
                'category' => $habitatType
              , 'format'    => $type
              , 'obligatoire'    => $obligatoire
              , 'nomParam'    => $nomParam
              , 'type'  => 'ajout'
            );
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($propriete);
            $entityManager->flush();

            //Ajout d'une notification
            $notification->setTitre("Ajout d'un paramètre");
            $parametre = $propriete->getIdTypeHabitat()->getNom() ;
            $notification->setContenu("Un nouveau paramètre à été ajouté pour les ".$parametre);
            $notification->setIdTypeHabitat($propriete->getIdTypeHabitat());
            $entityManager->persist($notification);
            $entityManager->flush();

            // Notification Stuff
            $context = new \ZMQContext();
            $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
            $socket->connect("tcp://localhost:5555");
        
            $socket->send(json_encode($entryData));
            return $this->redirectToRoute('proprietes');
    

        }


        return $this->render('proprietes_add.html.twig', [
            'controller_name' => 'GerantController', 'propriete' => $propriete, 'form' => $form->createView(),
        ]);
    }

        /**
     * @Route("/{id}/edit", name="proprietes_edit", methods={"GET","POST"})
     */
    public function editProperty(Request $request, Propriete $propriete): Response
    {
        $form = $this->createForm(Propriete1Type::class, $propriete);
        $form->handleRequest($request);
        $notification = new Notification();


        if ($form->isSubmitted() && $form->isValid()) {

            $nomParam = $form->get('nom')->getData();
            $habitatType = $form->get('idTypeHabitat')->getData()->getNom();
            $type = $form->get('type')->getData();
            $obligatoire = $form->get('obligatoire')->getData();
            if ($obligatoire == true) {
                $obligatoire = "oui" ;
            }
            else {
                $obligatoire = "non" ;
            }
            $entryData = array(
                'category' => $habitatType
              , 'format'    => $type
              , 'obligatoire'    => $obligatoire
              , 'nomParam'    => $nomParam
              , 'type'  => 'modification'
            );

            $notification->setTitre("Modification d'un paramètre");
            $entityManager = $this->getDoctrine()->getManager();
            $parametre = $propriete->getIdTypeHabitat()->getNom() ;
            $notification->setContenu("Un paramètre à été modifié pour les ".$parametre);
            $notification->setIdTypeHabitat($propriete->getIdTypeHabitat());
            $entityManager->persist($notification);
            $entityManager->flush();

            $this->getDoctrine()->getManager()->flush();

            // Notification Stuff
            $context = new \ZMQContext();
            $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
            $socket->connect("tcp://localhost:5555");
        
            $socket->send(json_encode($entryData));
            return $this->redirectToRoute('proprietes');
        }

        return $this->render('propriete/edit.html.twig', [
            'propriete' => $propriete,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/proprietes/{id}", name="proprietes_delete", methods={"DELETE"})
     */
    public function delete(Request $request, Propriete $propriete): Response
    {
        if ($this->isCsrfTokenValid('delete'.$propriete->getId(), $request->request->get('_token'))) {
            
            $nomParam = $propriete->getNom();
            $habitatType = $propriete->getIdTypeHabitat()->getNom();
            $type = $propriete->getType();
            $obligatoire = $propriete->getObligatoire();
            if ($obligatoire == true) {
                $obligatoire = "oui" ;
            }
            else {
                $obligatoire = "non" ;
            }
            $entryData = array(
                'category' => $habitatType
              , 'format'    => $type
              , 'obligatoire'    => $obligatoire
              , 'nomParam'    => $nomParam
              , 'type'  => 'modification'
            );


            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($propriete);
            $entityManager->flush();
            $notification->setTitre("Supprimer d'un paramètre");
            $parametre = $propriete->getIdTypeHabitat()->getNom() ;
            $notification->setContenu("Un paramètre à été supprimé pour les ".$parametre);
            $notification->setIdTypeHabitat($propriete->getIdTypeHabitat());
            $entityManager->persist($notification);
            $entityManager->flush();
        }

        return $this->redirectToRoute('proprietes');
    }
    /**
     * @Route("/comments", name="comments")
     */
    public function comments(CommentaireRepository $commentaireRepository): Response
    {
        return $this->render('comment_backoff.html.twig', [
            'controller_name' => 'GerantController', 'comments' => $commentaireRepository->findAll()
        ]);
    }
    
    /**
     * @Route("/photos", name="photos")
     */
    public function photos(PriseDeVueRepository $prisedevueRepository): Response
    {
        return $this->render('photos_backoff.html.twig', [
            'controller_name' => 'GerantController', 'photos' => $prisedevueRepository->findAll()
        ]);
    }
       /**
     * @Route("/{id}", name="typesActivites_show", methods={"GET"})
     */
    public function show(Activite $activite): Response
    {
        return $this->render('typeActivite_show.html.twig', [
            'activites' => $activite 
        ]);
    }
    /**
     * @Route("/typeActivites/add", name="typeActivites/add" , methods={"GET","POST"})
     */
    public function addTypeActivite(Request $request): Response
    {

        $activite = new Activite();
        $form = $this->createForm(Activite1Type::class, $activite);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($activite);
            $entityManager->flush();

            return $this->redirectToRoute('typeActivites');
        }

        return $this->render('typeActivite_add.html.twig', [
            'controller_name' => 'GerantController', 'activite' => $activite, 'form' => $form->createView(),
        ]);
    }
    /**
     * @Route("/{id}", name="typesActivites_edit", methods={"GET","POST"})
     */
    public function edit(Activite $activite, Request $request): Response
    {
        $form = $this->createForm(Activite1Type::class, $activite);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('typesActivites');
        }

        return $this->render('typesActivites_edit.html.twig', [
            'activites' => $activite,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/typesActivites/{id}", name="typeActivites_delete", methods={"DELETE"})
     */
    public function deleteTypeActivite(Activite $activite, Request $request): Response
    {
        if ($this->isCsrfTokenValid('delete'.$activite->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($activite);
            $entityManager->flush();
        }

        return $this->redirectToRoute('typeActivites');
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Calendrier;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use App\Form\CalendarHabitatType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;


class CalendarHabitatType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('dateDispo', DateType::class, [
            'widget' => 'single_text',
            'format' => 'dd/MM/yyyy',
            // prevents rendering it as type="date", to avoid HTML5 date pickers
            'html5' => false,
            // adds a class that can be selected in JavaScript
        ])
        ->add('etat' , ChoiceType::class, [
            'choices'  => [
                'Disponible' => "D",
                'Occupé' => "O",
            ]
        ])
        ->add('save', SubmitType::class, [
            'attr' => ['class' => 'stripe-button'],
        ]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Calendrier::class,
        ]);
    }
}
<file_sep><?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;


/**
 * User
 *
 * @ORM\Table(name="user", uniqueConstraints={@ORM\UniqueConstraint(name="UNIQ_8D93D649AA08CB10", columns={"login"})})
 * @ORM\Entity
 * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
 */
class User implements UserInterface
{
    /**
     * @var int
     * @Groups("location:info")
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @Assert\Unique
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="login", type="string", length=180, nullable=false)
     */
    private $login;

    /**
     * @var json
     * @Groups("location:info")
     * @ORM\Column(name="roles", type="json", nullable=false)
     */
    private $roles;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="password", type="string", length=255, nullable=false)
     */
    private $password;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="nom", type="string", length=50, nullable=false)
     */
    private $nom;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="prenom", type="string", length=50, nullable=false)
     */
    private $prenom;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="adresse", type="string", length=150, nullable=false)
     */
    private $adresse;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="ville", type="string", length=40, nullable=false)
     */
    private $ville;

    /**
     * @var int
     * @Groups("location:info")
     * @ORM\Column(name="cp", type="integer", nullable=false)
     */
    private $cp;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="url", length=65535)
     */
    private $url;

    /**
     * @Groups("location:info")
     * @ORM\Column(name="email", type="string", length=45)
     */
    private $email;

    /**
     * @Groups("location:info")
     * @ORM\Column(type="date")
     */
    private $dateNaissance;

    /**
     * @Groups("location:info")
     * @ORM\Column(type="string", length=255)
     */
    private $genre;

    /**
     * @Groups("location:info")
     * @ORM\Column(type="integer")
     */
    private $telephone;

    /**
     * @Groups("location:info")
     * @ORM\Column(type="text", nullable=true)
     */
    private $biographie;


    /**
     * Constructor
     */
    public function __construct()
    {
        $this->url = "images/userDefault.svg";
        $this->users = new ArrayCollection();

    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getLogin(): ?string
    {
        return $this->login;
    }

    public function setLogin(string $login): self
    {
        $this->login = $login;

        return $this;
    }

    public function getRoles(): array
    {
        $roles = $this->roles;
        // guarantee every user at least has ROLE_USER
        $roles[] = 'ROLE_USER';

        return array_unique($roles);
    }


    public function setRoles(array $roles): self
    {
        $this->roles = $roles;

        return $this;
    }

    public function getPassword(): ?string
    {
        return $this->password;
    }

    public function setPassword(string $password): self
    {
        $this->password = $password;

        return $this;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }

    public function getPrenom(): ?string
    {
        return $this->prenom;
    }

    public function setPrenom(string $prenom): self
    {
        $this->prenom = $prenom;

        return $this;
    }

    public function getAdresse(): ?string
    {
        return $this->adresse;
    }

    public function setAdresse(string $adresse): self
    {
        $this->adresse = $adresse;

        return $this;
    }

    public function getVille(): ?string
    {
        return $this->ville;
    }

    public function setVille(string $ville): self
    {
        $this->ville = $ville;

        return $this;
    }

    public function getCp(): ?int
    {
        return $this->cp;
    }

    public function setCp(int $cp): self
    {
        $this->cp = $cp;

        return $this;
    }

    public function getUrl(): ?string
    {
        return $this->url;
    }

    public function setUrl(string $url): self
    {
        $this->url = $url;

        return $this;
    }
    public function getSalt()
    {
        // you *may* need a real salt depending on your encoder
        // see section on salt below
        return null;
    }
       /**
     * @see UserInterface
     */
    public function eraseCredentials()
    {
        // If you store any temporary, sensitive data on the user, clear it here
        // $this->plainPassword = null;
    }
    



    public function getEmail(): ?string
    {
        return $this->email;
    }

    public function setEmail(string $email): self
    {
        $this->email = $email;

        return $this;
    }

    public function getGenre(): ?string
    {
        return $this->genre;
    }

    public function setGenre(string $genre): self
    {
        $this->genre = $genre;

        return $this;
    }
    public function getUsername()
    {
        return $this->email;
    }

    public function getDateNaissance(): ?\DateTimeInterface
    {
        return $this->dateNaissance;
    }

    public function setDateNaissance(\DateTimeInterface $dateNaissance): self
    {
        $this->dateNaissance = $dateNaissance;

        return $this;
    }

    public function getTelephone(): ?int
    {
        return $this->telephone;
    }

    public function setTelephone(int $telephone): self
    {
        $this->telephone = $telephone;

        return $this;
    }

    public function getBiographie(): ?string
    {
        return $this->biographie;
    }

    public function setBiographie(?string $biographie): self
    {
        $this->biographie = $biographie;

        return $this;
    }

}
<file_sep><?php
namespace App\WebSocket;

use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;
use App\WebSocket\Pusher;
use React\EventLoop\Factory ;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;


class PusherServerCommand extends Command
{
    protected static $defaultName = "pusher-server";
 
    protected function execute(InputInterface $input, OutputInterface $output)
    {

        $loop   = \React\EventLoop\Factory::create();
        $pusher = new \App\WebSocket\Pusher;
    
        // Listen for the web server to make a ZeroMQ push after an ajax request
        $context = new \React\ZMQ\Context($loop);
        $pull = $context->getSocket(\ZMQ::SOCKET_PULL);
        $pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself
        $pull->on('message', array($pusher, 'onBlogEntry'));
    
        // Set up our WebSocket server for clients wanting real-time updates
        $webSock = new \React\Socket\Server('0.0.0.0:8080', $loop); // Binding to 0.0.0.0 means remotes can connect
        $output->writeln("Serveur Démarré");        
        $webServer = new \Ratchet\Server\IoServer(
            new \Ratchet\Http\HttpServer(
                new \Ratchet\WebSocket\WsServer(
                    new \Ratchet\Wamp\WampServer(
                        $pusher
                    )
                )
            ),
            $webSock
        );
    
        $loop->run();
    }
}
?><file_sep><?php

namespace App\Controller;

use App\Entity\User;
use App\Form\User1Type;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use App\Form\InscriptionUserType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("users")
 */
class UserController extends AbstractController
{
    /**
     * @Route("/", name="user", methods={"GET"})
     */
    public function index(): Response
    {
        $users = $this->getDoctrine()
            ->getRepository(User::class)
            ->findAll();

        return $this->render('user/index.html.twig', [
            'users' => $users,
        ]);
    }

    /**
     * @Route("/new", name="user_new", methods={"GET","POST"})
     */
    public function new(Request $request, UserPasswordEncoderInterface $passwordEncoder): Response
    {
        $user = new User();
        $form = $this->createForm(User1Type::class, $user);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $user->setRoles(['ROLE_ADMIN']) ;
            $password = $passwordEncoder->encodePassword($user, $user->getPassword());
            $user->setPassword($password);

            $entityManager->persist($user);
            $entityManager->flush();

            return $this->redirectToRoute('user');
        }

        return $this->render('user/new.html.twig', [
            'user' => $user,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="user_show", methods={"GET"})
     */
    public function show(User $user): Response
    {
        return $this->render('user/show.html.twig', [
            'user' => $user,
        ]);
    }

    /**
     * @Route("/{id}/edit", name="user_edit", methods={"GET","POST"})
     */
    public function edit(Request $request, User $user, UserPasswordEncoderInterface $encoder): Response
    {
        $form = $this->createForm(User1Type::class, $user);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $imageurl = $form->get('url')->getData();
            $motdepasse = $form->get('password')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('profil_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);
            $encoded = $encoder->encodePassword($user, $motdepasse);
            $user->setUrl($fichier);
            $user->setPassword($encoded);
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('user');
        }

        return $this->render('user/edit.html.twig', [
            'user' => $user,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="user_delete", methods={"DELETE"})
     */
    public function delete(Request $request, User $user): Response
    {
        if ($this->isCsrfTokenValid('delete'.$user->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($user);
            $entityManager->flush();
        }

        return $this->redirectToRoute('user_index');
    }
}
<file_sep><?php

namespace App\Controller;

use App\Entity\ProprieteHabitat;
use App\Entity\User;
use App\Form\ProprieteHabitatType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/proprietehabitat")
 */
class ProprieteHabitatController extends AbstractController
{
    /**
     * @Route("/", name="propriete_habitat_index", methods={"GET"})
     */
    public function index(): Response
    {
        
        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $proprieteHabitats = $this->getDoctrine()
            ->getRepository(ProprieteHabitat::class)
            ->findAll();

        return $this->render('propriete_habitat/index.html.twig', [
            'propriete_habitats' => $proprieteHabitats, 'profil' => $profil
        ]);
    }

    /**
     * @Route("/new", name="propriete_habitat_new", methods={"GET","POST"})
     */
    public function new(Request $request): Response
    {
        $proprieteHabitat = new ProprieteHabitat();
        $form = $this->createForm(ProprieteHabitatType::class, $proprieteHabitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($proprieteHabitat);
            $entityManager->flush();

            return $this->redirectToRoute('propriete_habitat_index');
        }

        return $this->render('propriete_habitat/new.html.twig', [
            'propriete_habitat' => $proprieteHabitat,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="propriete_habitat_show", methods={"GET"})
     */
    public function show(ProprieteHabitat $proprieteHabitat): Response
    {
        return $this->render('propriete_habitat/show.html.twig', [
            'propriete_habitat' => $proprieteHabitat,
        ]);
    }

    /**
     * @Route("/{id}/edit", name="propriete_habitat_edit", methods={"GET","POST"})
     */
    public function edit(Request $request, ProprieteHabitat $proprieteHabitat): Response
    {
        $form = $this->createForm(ProprieteHabitatType::class, $proprieteHabitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('propriete_habitat_index');
        }

        return $this->render('propriete_habitat/edit.html.twig', [
            'propriete_habitat' => $proprieteHabitat,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="propriete_habitat_delete", methods={"DELETE"})
     */
    public function delete(Request $request, ProprieteHabitat $proprieteHabitat): Response
    {
        if ($this->isCsrfTokenValid('delete'.$proprieteHabitat->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($proprieteHabitat);
            $entityManager->flush();
        }

        return $this->redirectToRoute('propriete_habitat_index');
    }
}
<file_sep><?php

namespace App\Controller;

use App\Entity\PriseDeVue;
use App\Form\PriseDeVueType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use App\Repository\PriseDeVueRepository;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/prisedevue")
 */
class PriseDeVueController extends AbstractController
{

        /**
     * @Route("/", name="prisedevue_index", methods={"GET"})
     */
    public function index(PriseDeVueRepository $PriseDeVueRepository): Response
    {
        return $this->render('prise_de_vue/index.html.twig', [
            'prise_de_vues' => $PriseDeVueRepository->findAll(),
        ]);
    }

    /**
     * @Route("/{id}", name="prisedevue_show", methods={"GET"})
     */
    public function show(PrisedeVue $prisedevue): Response
    {
        return $this->render('prise_de_vue/show.html.twig', [
            'prise_de_vue' => $prisedevue,
        ]);
    }
    /**
     * @Route("/newPhoto/{idHabitat}", name="prisedevue_new", methods={"GET","POST"})
     */
    public function new(Request $request, Habitat $habitat): Response
    {
        $priseDeVue = new PriseDeVue();
        $form = $this->createForm(PriseDeVueType::class, $priseDeVue);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($priseDeVue);
            $entityManager->flush();

            return $this->redirectToRoute('prise_de_vue_index');
        }

        return $this->render('prise_de_vue/new.html.twig', [
            'prise_de_vue' => $priseDeVue,
            'form' => $form->createView(),
        ]);
    }

}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use App\Entity\Habitat ;
use App\Form\ContactOwnerType;
use App\Entity\PriseDeVue ;
use Symfony\Component\Routing\Annotation\Route;
class ContactController extends AbstractController
{
    /**
     * @Route("/contact", name="contact")
     */
    public function index(Request $request, MailerInterface $mailer): Response
    {
        $user = $this->getUser();
        $contact = $this->createForm(ContactOwnerType::class);
        $contact->handleRequest($request);

        if ($contact->isSubmitted() && $contact->isValid()) {
            $expediteur = $contact->get('email')->getData();
            $objet = $contact->get('objet')->getData();
            $contenu = $contact->get('contenu')->getData();
            $destinataire = $user->getEmail();
            $email = (new Email())
            ->from($expediteur)
            ->to('<EMAIL>')
            ->subject($objet)
            ->text($contenu);
            
            $mailer->send($email);

            return $this->redirectToRoute('home');
        }
        return $this->render('contact/index.html.twig', [
            'controller_name' => 'ContactController', 'contact' => $contact->createView()
        ]);
    }
    /**
     * @Route("/contact_owner/{id}", name="contact_owner")
     */
    public function sendEmail(Habitat $habitats, MailerInterface $mailer)
    {

        $habitat = new Habitat();
        $user = $this->getUser();
        $form = $this->createForm(ContactType::class, $habitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {

            $envoyeur = $habitat->getIdProprietaire()->getEmail();
            $destinataire = $user->getEmail();
            $email = (new Email())
            ->from($envoyeur)
            ->to($destinataire)
            //->cc('<EMAIL>')
            //->bcc('<EMAIL>')
            //->replyTo('<EMAIL>')
            //->priority(Email::PRIORITY_HIGH)
            ->subject($data['sujet'])
            ->text($data['contenu']);
            
            $mailer->send($email);

            return $this->redirectToRoute('listHabitat');
        }

        return $this->render('contact/index.html.twig', [
            'habitat' => $habitat,
            'form' => $form->createView(),

        ]);

        // ...
}
}<file_sep><?php

namespace App\Repository;

use App\Entity\DispoDomaine;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @method DispoDomaine|null find($id, $lockMode = null, $lockVersion = null)
 * @method DispoDomaine|null findOneBy(array $criteria, array $orderBy = null)
 * @method DispoDomaine[]    findAll()
 * @method DispoDomaine[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class DispoDomaineRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, DispoDomaine::class);
    }

    // /**
    //  * @return DispoDomaine[] Returns an array of DispoDomaine objects
    //  */
    /*
    public function findByExampleField($value)
    {
        return $this->createQueryBuilder('d')
            ->andWhere('d.exampleField = :val')
            ->setParameter('val', $value)
            ->orderBy('d.id', 'ASC')
            ->setMaxResults(10)
            ->getQuery()
            ->getResult()
        ;
    }
    */

    /*
    public function findOneBySomeField($value): ?DispoDomaine
    {
        return $this->createQueryBuilder('d')
            ->andWhere('d.exampleField = :val')
            ->setParameter('val', $value)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
    */
}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Form\WebSocketTestType;
use Symfony\Component\HttpFoundation\Request;

class WebSocketController extends AbstractController
{
    /**
     * @Route("/websocket", name="web_socket")
     */
    public function index(): Response
    {
        $form = $this->createForm(WebSocketTestType::class);
        $request = Request::createFromGlobals();

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $entryData = $form->getData();
            $context = new \ZMQContext();
            $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
            $socket->connect("tcp://localhost:5555");
        
            $socket->send(json_encode($entryData));
        
        }
        // This is our new stuff

        return $this->render('web_socket/index.html.twig', [
            'controller_name' => 'WebSocketController',
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/testwb", name="web_socket_test")
     */
    public function blankTest(): Response
    {
    
        return $this->render('web_socket/blankp.html.twig', [
            'controller_name' => 'WebSocketController',
        ]);
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Commentaire;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class CommentaireType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('titre' , TextType::class)
            ->add('contenu' , TextareaType::class , [
                'row_attr' => ['class' => 'commentBox']
            ])
            
            ->add('rechercher' , SubmitType::class, [
                'attr' => ['class' => 'btn-edit-profile '],

            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Commentaire::class,
        ]);
    }
}
<file_sep><?php

namespace App\Entity;

use App\Repository\RegionRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity(repositoryClass=RegionRepository::class)
 */
class Region
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @Assert\Unique
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank
     */
    private $nom;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Assert\Image(
     * minWidth = 1300,
     * maxWidth = 1900,
     * minHeight = 900,
     * maxHeight = 1400,
     * allowLandscape = false,
     * allowPortrait = false
     * )
     */
    private $image;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }

    public function getImage(): ?string
    {
        return $this->image;
    }

    public function setImage(?string $image): self
    {
        $this->image = $image;

        return $this;
    }
}
<file_sep><?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;

/**
 * Habitat
 *
 * @ORM\Table(name="habitat", indexes={@ORM\Index(name="IDX_3B37B2E85BA3388B", columns={"id_type_habitat_id"})})
 * @ORM\Entity
 */
class Habitat
{
    /**
     * @var int
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @Groups("location:info")
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="nom", type="string", length=30, nullable=false)
     */
    private $nom;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="nb_couchages", type="string", length=25, nullable=false)
     */
    private $nbCouchages;

    /**
     * @var int
     * @Groups("location:info")
     * @ORM\Column(name="capacite", type="integer", nullable=false)
     */
    private $capacite;

    /**
     * @var float
     * @Groups("location:info")
     * @ORM\Column(name="prix", type="float", precision=10, scale=0, nullable=false)
     */
    private $prix;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="pays", type="string", length=30, nullable=false)
     */
    private $pays;

    /**
     * @var string
     * @ORM\Column(name="ville", type="string", length=40, nullable=false)
     * @Groups("location:info")
     */
    private $ville;

    /**
     * @var string
     * @ORM\Column(name="description", type="text", length=0, nullable=false)
     * @Groups("location:info")
     */
    private $description;

    /**
     * @var \DateTime
     * @ORM\Column(name="date_publication", type="date", nullable=false)
     * @Groups("location:info")
     */
    private $datePublication;

    /**
     * @var string
     * @Groups("location:info")
     * @ORM\Column(name="url", type="text", length=65535, nullable=false)
     */
    private $url;

    /**
     * @var \TypeHabitat
     *
     * @ORM\ManyToOne(targetEntity="TypeHabitat")
     * @ORM\JoinColumns({
     * @ORM\JoinColumn(name="id_type_habitat_id", referencedColumnName="id")
     * })
     * @Groups("location:info")
     */
    private $idTypeHabitat;


    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToMany(targetEntity="ActiviteHabitat", mappedBy="habitat")
     */
    private $activiteHabitat;

    /**
     * @ORM\ManyToMany(targetEntity=Notification::class, mappedBy="idHabitat")
     */
    private $notification;

    /**
     * @ORM\ManyToOne(targetEntity=Domaine::class)
     * @ORM\JoinColumn(nullable=false)
     * @Groups("location:info")
     */
    private $idDomaine;

    /**
     * @ORM\ManyToMany(targetEntity=Propriete::class)
     */
    private $propriete;

    /**
     * @ORM\ManyToOne(targetEntity=Region::class)
     * @Groups("location:info")
     */
    private $region;



    /**
     * Constructor
     */
    public function __construct()
    {
        $this->activiteHabitat = new \Doctrine\Common\Collections\ArrayCollection();
        $this->notification = new ArrayCollection();
        $this->datePublication = new \DateTime('now');
        $this->url = "images/defaultHabitat.svg";
        $this->propriete = new ArrayCollection();

    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }

    public function getNbCouchages(): ?string
    {
        return $this->nbCouchages;
    }

    public function setNbCouchages(string $nbCouchages): self
    {
        $this->nbCouchages = $nbCouchages;

        return $this;
    }

    public function getCapacite(): ?int
    {
        return $this->capacite;
    }

    public function setCapacite(int $capacite): self
    {
        $this->capacite = $capacite;

        return $this;
    }

    public function getPrix(): ?float
    {
        return $this->prix;
    }

    public function setPrix(float $prix): self
    {
        $this->prix = $prix;

        return $this;
    }

    public function getPays(): ?string
    {
        return $this->pays;
    }

    public function setPays(string $pays): self
    {
        $this->pays = $pays;

        return $this;
    }

    public function getVille(): ?string
    {
        return $this->ville;
    }

    public function setVille(string $ville): self
    {
        $this->ville = $ville;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(string $description): self
    {
        $this->description = $description;

        return $this;
    }

    public function getDatePublication(): ?\DateTimeInterface
    {
        return $this->datePublication;
    }

    public function setDatePublication(\DateTimeInterface $datePublication): self
    {
        $this->datePublication = $datePublication;

        return $this;
    }

    public function getUrl(): ?string
    {
        return $this->url;
    }

    public function setUrl(string $url): self
    {
        $this->url = $url;

        return $this;
    }

    public function getIdTypeHabitat(): ?TypeHabitat
    {
        return $this->idTypeHabitat;
    }

    public function setIdTypeHabitat(?TypeHabitat $idTypeHabitat): self
    {
        $this->idTypeHabitat = $idTypeHabitat;

        return $this;
    }


    /**
     * @return Collection|ActiviteHabitat[]
     */
    public function getActiviteHabitat(): Collection
    {
        return $this->activiteHabitat;
    }

    public function addActiviteHabitat(ActiviteHabitat $activiteHabitat): self
    {
        if (!$this->activiteHabitat->contains($activiteHabitat)) {
            $this->activiteHabitat[] = $activiteHabitat;
            $activiteHabitat->addHabitat($this);
        }

        return $this;
    }

    public function removeActiviteHabitat(ActiviteHabitat $activiteHabitat): self
    {
        if ($this->activiteHabitat->removeElement($activiteHabitat)) {
            $activiteHabitat->removeHabitat($this);
        }

        return $this;
    }

    /**
     * @return Collection|Notification[]
     */
    public function getNotification(): Collection
    {
        return $this->notification;
    }

    public function addNotification(Notification $notification): self
    {
        if (!$this->notification->contains($notification)) {
            $this->notification[] = $notification;
            $notification->addIdHabitat($this);
        }

        return $this;
    }

    public function removeNotification(Notification $notification): self
    {
        if ($this->notification->removeElement($notification)) {
            $notification->removeIdHabitat($this);
        }

        return $this;
    }

    public function getIdDomaine(): ?Domaine
    {
        return $this->idDomaine;
    }

    public function setIdDomaine(?Domaine $idDomaine): self
    {
        $this->idDomaine = $idDomaine;

        return $this;
    }

    /**
     * @return Collection|Propriete[]
     */
    public function getPropriete(): Collection
    {
        return $this->propriete;
    }

    public function addPropriete(Propriete $propriete): self
    {
        if (!$this->propriete->contains($propriete)) {
            $this->propriete[] = $propriete;
        }

        return $this;
    }

    public function removePropriete(Propriete $propriete): self
    {
        $this->propriete->removeElement($propriete);

        return $this;
    }

    public function getRegion(): ?Region
    {
        return $this->region;
    }

    public function setRegion(?Region $region): self
    {
        $this->region = $region;

        return $this;
    }

}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use App\Form\NewsletterType;
use App\Entity\Newsletter ;

class ContenuController extends AbstractController
{
    /**
     * @Route("/contenu", name="contenu")
     */
    public function index(): Response
    {
        return $this->render('contenu/index.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/questions", name="questions")
     */
    public function showFaq() {

        return $this->render('contenu/faq.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/searchfaq", name="searchfaq")
     */
    public function showFaqSearch() {

        return $this->render('contenu/faq/search_hab.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/bookingfaq", name="bookingfaq")
     */
    public function showFaqBooking() {

        return $this->render('contenu/faq./reservation_hab.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/calendarfaq", name="calendarfaq")
     */
    public function showFaqCalendar() {

        return $this->render('contenu/faq/dispo_hab.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/validerfaq", name="validerfaq")
     */
    public function showFaqValider() {

        return $this->render('contenu/faq/valider_res.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/gererfaq", name="gererfaq")
     */
    public function showFaqGerer() {

        return $this->render('contenu/faq/gerer_hab.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/paymentfaq", name="paymentfaq")
     */
    public function showFaqPayment() {

        return $this->render('contenu/faq/infos_payment.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/aboutsus", name="about_us")
     */
    public function showAbout() {

        return $this->render('contenu/faq.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
    /**
     * @Route("/mentions-legales", name="mentions_legales")
     */
    public function showMentions() {



        return $this->render('contenu/mentions.html.twig', [
            'controller_name' => 'ContenuController',
        ]);
    }
        /**
     * @Route("/newsletter", name="newsletter")
     */
    public function newsletter(Request $request) {

        $newsletter = new Newsletter();
        $form = $this->createForm(NewsletterType::class);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $newsletter = $form->getData();
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($newsletter);
            $entityManager->flush();
            return $this->redirectToRoute('home');
        }
        return $this->render('contenu/newsletter.html.twig', [
            'controller_name' => 'ContenuController', 'form' => $form->createView()
        ]);
    }

}
<file_sep><?php

namespace App\Controller;

use App\Entity\Commentaire;
use App\Repository\CommentaireRepository;
use App\Form\Commentaire1Type;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/commentaire")
 */
class CommentaireController extends AbstractController
{
    /**
     * @Route("/newComment/{idReservation}", name="commentaire_new", methods={"GET","POST"})
     */
    public function new(Reservation $reservation): Response
    {
        $commentaire = new Commentaire();
        $form = $this->createForm(Commentaire1Type::class, $commentaire);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($commentaire);
            $entityManager->flush();

            $this->addFlash('success', 'Votre commentaire a bien été posté !');

            return $this->redirectToRoute('internaute');

        }

        return $this->render('commentaire/new.html.twig', [
            'commentaire' => $commentaire,
            'form' => $form->createView(),
        ]);
    

        }

    /**
     * @Route("/newComment/{idHabitat}", name="commentaire_new", methods={"GET","POST"})
     */
    public function newCommentActivites(ActiviteHabitat $activiteHabitat): Response
    {
        $commentaire = new Commentaire();
        $form = $this->createForm(Commentaire1Type::class, $commentaire);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($commentaire);
            $entityManager->flush();

            return $this->redirectToRoute('commentaire_index');
        }

        return $this->render('commentaire/newActiviteComment.html.twig', [
            'commentaire' => $commentaire,
            'form' => $form->createView(),
        ]);
    

    }


    /**
     * @Route("/", name="comment_index", methods={"GET"})
     */
    public function index(CommentaireRepository $CommentaireRepository): Response
    {
        return $this->render('commentaire/index.html.twig', [
            'commentaires' => $CommentaireRepository->findAll(),
        ]);
    }

    /**
     * @Route("/{id}", name="comment_show", methods={"GET"})
     */
    public function show(Commentaire $comment): Response
    {
        return $this->render('commentaire/show.html.twig', [
            'commentaires' => $comment,
        ]);
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\FileType;

use Symfony\Component\OptionsResolver\OptionsResolver;

class User1Type extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
        ->add('login', TextType::class , ['label' => "Nom d'utilisateur"])
        ->add('password', PasswordType::class , ['label' => 'Mot de Passe']
        )
        ->add('email', EmailType::class , ['label' => 'Adresse E-Mail'])
        ->add('nom', TextType::class, ['label' => 'Nom'])
        ->add('prenom', TextType::class,['label' => 'Prénom'])
        ->add('adresse', TextType::class, ['label' => 'Adresse'])
        ->add('ville', TextType::class, ['label' => 'Ville'])
        ->add('cp', TextType::class, ['label' => 'Code Postal'])
        ->add('url', FileType::class , array('data_class' => null))
        ->add('dateNaissance')
        ->add('genre')
        ->add('telephone')
        ->add('biographie')
        ->add('save', SubmitType::class, [
            'attr' => ['class' => 'btn-edit-profile'],
        ]);        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => User::class,
        ]);
    }
}
<file_sep><?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request ;
use App\Form\DomaineType;
use App\Entity\User;
use App\Entity\Region ;
use App\Entity\ActiviteHabitat;
use App\Entity\Habitat;
use App\Entity\Location ;
use App\Entity\Activite;
use App\Entity\ProprieteHabitat;
use App\Entity\Calendrier;
use App\Entity\DispoDomaine;
use App\Form\DispoDomaineType;
use App\Form\DispoLogementType;
use App\Form\CalendarHabitatType;
use App\Form\DomaineCalendrierType;
use Doctrine\Common\Collections\ArrayCollection;

use App\Form\User1Type;
use App\Form\ActiviteHabitatType;
use App\Form\ActiviteType;
use App\Form\HabitatType;
use App\Form\ProprieteHabitatType;
use App\Entity\PriseDeVue;
use App\Entity\Propriete;
use App\Entity\Commentaire;
use App\Form\PriseDeVueType;
use App\Form\CommentaireType;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use App\Entity\Domaine ;
class ProfileController extends AbstractController
{
    /**
     * @Route("/profile", name="profile")
     */
    public function index(): Response
    {
        return $this->render('profile/index.html.twig', [
            'controller_name' => 'ProfileController',
        ]);
    }
    /**
     * @Route("internaute/meshabitats/", name="internaute_habitats")
     */
    public function showHabitats() {


        $user = 4 ;
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $domaine = $this->getDoctrine()->getRepository(Domaine::class)->findBy([ 'idProprietaire' => $user]); 
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->findBy([ 'idDomaine' => $domaine]);
        return $this->render('userinterface/meshabitats.html.twig', [
            'controller_name' => 'ProfileController', 'profil' => $profil , 'habitats' => $habitat 
        ]);
    }
        /**
     * @Route("internaute/{id}/meshabitats/new", name="internaute_habitats_new")
     */
    public function addHabitats(Request $request) {


        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $habitat = new Habitat();
        $repository = $this->getDoctrine()->getRepository(Domaine::class);
        $domaine = $repository->findOneBy([ 'idProprietaire' => $user]);
        $form = $this->createForm(HabitatType::class, $habitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $imageurl = $form->get('url')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('habitat_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);


            $habitat->setUrl($fichier);
            $habitat->setPays('France');
            $habitat->setIdDomaine($domaine);
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($habitat);
            $entityManager->flush();

            return $this->redirectToRoute('internaute_habitats_details', array( 'id' => $habitat->getId()));
        }
        return $this->render('userinterface/addhabitat.html.twig', [
            'controller_name' => 'ProfileController', 'profil' => $profil , 'habitat' => $habitat , 'form' => $form->createView(),

        ]);
    }
    /**
     * @Route("internaute/meshabitats/{id}", name="internaute_habitats_details")
     */
    public function detailsHabitats(int $id) {


        $user = 4 ;
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->find($id);

        $repository = $this->getDoctrine()->getRepository(Domaine::class);
        $domaine = $repository->findOneBy([ 'idProprietaire' => $user]);
        $type = $habitat->getIdTypeHabitat();
        $propriete = $this->getDoctrine()
        ->getRepository(Propriete::class)
        ->findby(['idTypeHabitat' => $type]);
        $proprieteHabitats = $this->getDoctrine()
        ->getRepository(ProprieteHabitat::class)
        ->findby(['IdHabitatPropriete' => $id]);
        $activite = $this->getDoctrine()->getRepository(Activite::class)->findBy([ 'idDomaine' => $domaine ]);
        $activiteHabitat = $this->getDoctrine()->getRepository(ActiviteHabitat::class)->findby(
            ['idHabitat' => $id],
            ['typeActivite' => 'ASC']
    );
        return $this->render('userinterface/meshabitatsdetails.html.twig', [
            'controller_name' => 'ProfileController', 'activites' => $activite ,'proprietes' => $propriete ,'profil' => $profil , 'proprieteHabitats' => $proprieteHabitats , 'habitat' => $habitat , 'activiteHabitats' => $activiteHabitat
        ]);
    }

    /**
     * @Route("internaute/meshabitats/{id}/calendar", name="internaute_habitats_calendar")
     */
    public function gererCalenderier(int $id) {

        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $domaine = $this->getDoctrine()->getRepository(Domaine::class)->findOneBy([ 'idProprietaire' => $user]);
        $dispoDomaine = $this->getDoctrine()->getRepository(DispoDomaine::class)->findBy([ 'idDomaine' => $domaine]);
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->find($id);
        $dispoHabitat = $this->getDoctrine()->getRepository(Calendrier::class)->findBy([ 'idHabitat' => $id]);
        if (empty($dispoHabitat)) {
            for ($i=0; $i <= count($dispoDomaine) ; $i++) { 
                $dateHabitat = new Calendrier();
                $dateHabitat->setDateDispo( $dispoDomaine[$i]->getDateDispo());
                $dateHabitat->setEtat("D");
                $dateHabitat->setIdHabitat($habitat);
                $entityManager = $this->getDoctrine()->getManager();
                $entityManager->persist($dateHabitat);
                $entityManager->flush();
            }
        }


        $dateUpdate = $this->getDoctrine()->getRepository(Calendrier::class)->findBy([ 'idHabitat' => $id ]) ;
        $originalDates = new ArrayCollection();
        for ($i=0; $i < count($dispoDomaine) ; $i++) { 
            $date = $dispoDomaine[$i];
            $originalDates->add($date);
        }
        $form = $this->createForm(DispoLogementType::class);
        $request = Request::createFromGlobals();

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $taille = count($form->get('dateDispo'));
            for ($i=0; $i < $taille ; $i++) { 
                
                $dateUpdate[$i]->setEtat($form->get('dateDispo')->getData()[$i]->getEtat());
                $entityManager = $this->getDoctrine()->getManager();
                $entityManager->flush();

            }
            return $this->redirectToRoute('internaute_habitats_calendar', array( 'id' => $habitat->getId() ));
        }    



        return $this->render('userinterface/calendarhabitat.html.twig', [
            'controller_name' => 'ProfileController',
            'form' => $form->createView(),
            'dateDomaines' => $originalDates,

        ]);
    }


    /**
     * @Route("internaute/meshabitats/{id}/edit", name="internaute_habitats_edit")
     */
    public function editHabitats(int $id, Request $request) {


        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->find($id);
        $form = $this->createForm(HabitatType::class, $habitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $imageurl = $form->get('url')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('habitat_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);
            $habitat->setUrl($fichier);
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('internaute_habitats_details', array( 'id' => $habitat->getId()));
        }
        return $this->render('userinterface/meshabitatsedit.html.twig', [
            'controller_name' => 'ProfileController', 'profil' => $profil , 'habitat' => $habitat , 'form' => $form->createView(),

        ]);
    }


    /**
     * @Route("internaute/{idHabitat}/activite/{id}/edit", name="internaute_activite_edit")
     */
    public function editActivite(int $id, Request $request, int $idHabitat) {


        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->find($idHabitat);
        $activite = $this->getDoctrine()->getRepository(Activite::class)->find($id);
        $activiteHabitat = new ActiviteHabitat();
        $form = $this->createForm(ActiviteHabitatType::class, $activiteHabitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {

            $activiteHabitat = $form->getData();
            $activiteHabitat->setTypeActivite($activite);
            $activiteHabitat->setIdHabitat($habitat);
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($activiteHabitat);
            $entityManager->flush();
            return $this->redirectToRoute('internaute_habitats_details', array( 'id' => $habitat->getId()));
        }
        return $this->render('userinterface/activite_edit.html.twig', [
            'controller_name' => 'ProfileController', 'profil' => $profil , 'habitat' => $habitat, 'activite' => $activiteHabitat , 'form' => $form->createView(),

        ]);

    
    }

    /**
     * @Route("internaute/mondomaine/", name="internaute_domaine")
    */
    public function showDomaine() {

        $user = 4 ;
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $repository = $this->getDoctrine()->getRepository(Domaine::class);
        $domaine = $repository->findBy([ 'idProprietaire' => $user]);
        $activite = $this->getDoctrine()->getRepository(Activite::class)->findBy([ 'idDomaine' => $domaine ]);

        
        return $this->render('userinterface/mondomaine.html.twig', [
            'controller_name' => 'ProfileController', 'domaines' => $domaine , 'profil' => $profil , 'activites' => $activite
        ]);
    }
    /**
     * @Route("internaute/mondomaine/{id}/calendar", name="internaute_domaine_calendar")
     */
    public function gererCalenderierDomaine(int $id) {

        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $domaine = $this->getDoctrine()->getRepository(Domaine::class)->findOneBy([ 'idProprietaire' => $user]);
        $habitats = $this->getDoctrine()->getRepository(Habitat::class)->findBy([ 'idDomaine' => $domaine]);
        $dispoDomaine = $this->getDoctrine()->getRepository(DispoDomaine::class)->findBy([ 'idDomaine' => $domaine]);
        $originalDates = new Domaine() ;
        for ($i=0; $i < count($dispoDomaine) ; $i++) { 
            $date[$i] = $dispoDomaine[$i];
            $originalDates->getDispoDomaine()->add($date[$i]);
        }
        $form = $this->createForm(DomaineCalendrierType::class, $originalDates);
        $request = Request::createFromGlobals();

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            
            $taille = count($form->get('dispoDomaine'));

            // Ajout des Dates
            for ($i=0; $i < $taille ; $i++) { 
                $dateDispo = $form->get('dispoDomaine')->getData()[$i] ;
                $dateDispo->setIdDomaine($domaine) ;
                $entityManager = $this->getDoctrine()->getManager();
                $entityManager->persist($dateDispo);
                $entityManager->flush();

            }
            //Ajout des Dates pour chaque logement
            foreach ($habitats as $habitat) {
                for ($i=0; $i < $taille ; $i++) { 
                    $dispoHabitat = new Calendrier();
                    $dispoHabitat->setIdHabitat($habitat);
                    $dispoHabitat->setDateDispo($form->get('dispoDomaine')->getData()[$i]->getDateDispo());
                    $dispoHabitat->setEtat("D");
                    $dispoHabitatBDD = $this->getDoctrine()->getRepository(Calendrier::class)->findOneBy([ 'idHabitat' => $habitat->getId() , 'dateDispo' => $form->get('dispoDomaine')->getData()[$i]->getDateDispo() ]);
                    if ($dispoHabitatBDD == null) {
                        $entityManager->persist($dispoHabitat);
                        $entityManager->flush();
                    }
                }
            }


            //Suppression des Dates 
            foreach ($dispoDomaine as $dates) {
                if (false === $originalDates->getDispoDomaine()->contains($dates)) {
                    $entityManager->remove($dates);
                    $entityManager->flush();

                }
            }

            return $this->redirectToRoute('internaute_domaine_calendar', array( 'id' => $domaine->getId() ));


            // $form->getData() holds the submitted values
            // but, the original `$task` variable has also been updated

            // ... perform some action, such as saving the task to the database


        }       



        return $this->render('userinterface/calendardomaine.html.twig', [
            'controller_name' => 'ProfileController',
            'form' => $form->createView(),
            'dispoDomaine' => $dispoDomaine,

        ]);
    }
        /**
     * @Route("internaute/mondomaine/new", name="internaute_domaine_new")
     */
    public function addDomaine(Request $request) {


        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $domaine = new Domaine();
        $form = $this->createForm(DomaineType::class, $domaine);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $imageurl = $form->get('image')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('domaine_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);
            $domaine->setImage($fichier);
            $entityManager = $this->getDoctrine()->getManager();
            $domaine->setIdProprietaire($this->getUser());
            $entityManager->persist($domaine);
            $entityManager->flush();
            return $this->redirectToRoute('internaute_domaine');
        }
        return $this->render('userinterface/adddomaine.html.twig', [
            'controller_name' => 'ProfileController', 'profil' => $profil , 'form' => $form->createView(),

        ]);
    }
    /**
     * @Route("internaute/mondomaine/{id}/edit", name="internaute_domaine_edit" , methods={"GET","POST"})
     */
    public function editDomaine(Request $request, Domaine $domaine) {

        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $form = $this->createForm(DomaineType::class, $domaine);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $imageurl = $form->get('image')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('domaine_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);
            $domaine->setImage($fichier);
            $domaine->setPays('France');
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('internaute_domaine');
        }

        return $this->render('userinterface/domainedit.html.twig', [
            'domaine' => $domaine,
            'form' => $form->createView(),
            'profil' => $profil
        ]);
    }
    /**
     * @Route("internaute/profil/{id}/edit", name="internaute_profil_edit" , methods={"GET","POST"})
     */
    public function editProfil(Request $request, User $user, UserPasswordEncoderInterface $encoder) {

        $form = $this->createForm(User1Type::class, $user);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $imageurl = $form->get('url')->getData();
            $motdepasse = $form->get('password')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('profil_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);
            $encoded = $encoder->encodePassword($user, $motdepasse);
            $user->setUrl($fichier);
            $user->setPassword($encoded);
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('internaute');
        }

        return $this->render('userinterface/editprofile.html.twig', [
            'profil' => $user,
            'form' => $form->createView(),
        ]);
    }
        /**
     * @Route("internaute/location", name="internaute_location")
     */
    public function showLocation() {

        $idUser = 4 ;
        $profil = $this->getDoctrine()->getRepository(User::class)->find($idUser);
        $repository = $this->getDoctrine()->getRepository(Location::class);
        $user = $this->getDoctrine()->getRepository(User::class)->find($idUser);
        $historique = $repository->findby(['idUserLocataire' => $user , 'statut' => "En Attente"]);
        
        
        return $this->render('userinterface/showLocation.html.twig', [
            'controller_name' => 'InternauteController', 'locations' => $historique , 'profil' => $profil
        ]);

    }
    /**
     * @Route("internaute/location/activite/{id}", name="internaute_location_activite")
     */
    public function showActivite(int $id, Request $request) {

        $activite = $this->getDoctrine()->getRepository(ActiviteHabitat::class)->find($id);
        $photos = $this->getDoctrine()->getRepository(PriseDeVue::class)->findby(
            [ 'idActiviteHabitat' => $activite->getId() ]
        );
        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $photo = $this->createForm(PriseDeVueType::class);
        $form = $this->createForm(CommentaireType::class);
        $commentaire = new Commentaire();
        $prisedevue = new PriseDeVue();
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {

            $commentaire = $form->getData();
            $commentaire->setIdUser($this->getUser());
            $commentaire->setIdActiviteHabitat($activite);
            // ... do any other work - like sending them an email, etc
            // maybe set a "flash" success message for the user
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($commentaire);
            $entityManager->flush();

            return $this->redirectToRoute('internaute_location_activite', ['id' => $activite->getId() ]);

        }       
        if ($photo->isSubmitted() && $photo->isValid()) {

            $prisedevue = $photo->getData();
            // ... do any other work - like sending them an email, etc
            // maybe set a "flash" success message for the user
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($prisedevue);
            $entityManager->flush();

            return $this->redirectToRoute('internaute_location_activite', ['id' => $activite->getId() ]);

        }   
        
        return $this->render('userinterface/activitedetailsuser.html.twig', [
            'controller_name' => 'InternauteController' , 'profil' => $profil , 'activite' => $activite , 'form' => $form->createView() , 'photo' => $photo->createView()
        ]);

    }

    /**
     * @Route("internaute/{id}/propriete", name="internaute_propriete_index", methods={"GET"})
    */
    public function showProperty(int $id, Request $request): Response
    {
        
        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->find($id);
        $proprieteForm = $this->createForm(ProprieteHabitatType::class); 
        $type = $habitat->getIdTypeHabitat();
        $proprieteForm->handleRequest($request);
        $proprieteHabitats = $this->getDoctrine()
        ->getRepository(Propriete::class)
        ->findby(['idTypeHabitat' => $type]);
        return $this->render('propriete_habitat/index.html.twig', [
            'propriete_habitats' => $proprieteHabitats, 'profil' => $profil, 'form' => $proprieteForm->createView(), 'habitat' => $habitat
        ]);
    }
    /**
     * @Route("internaute/propriete/{idHabitat}/{id}/edit", name="internaute_propriete_edit" , methods={"GET", "POST"})
     */
    public function editProperty(int $id, Request $request, int $idHabitat): Response
    {
        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $proprieteForm = $this->createForm(ProprieteHabitatType::class); 
        $habitat = $this->getDoctrine()->getRepository(Habitat::class)->find($idHabitat);
        $proprieteForm->handleRequest($request);
        $proprieteHabitats = $this->getDoctrine()->getRepository(Propriete::class)->findOneby(['id' => $id]);
        if ($proprieteForm->isSubmitted() && $proprieteForm->isValid()) {
            $data = $proprieteForm->get('valeurPropriete')->getData();
            $propriete = new ProprieteHabitat();
            $propriete->setIdHabitatPropriete($habitat);
            $propriete->setIdPropriete($proprieteHabitats);
            $propriete->setValeurPropriete($data);
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($propriete);
            $entityManager->flush();
            return $this->redirectToRoute('internaute_propriete_index');
        }
        return $this->render('propriete_habitat/edit.html.twig', [
            'propriete' => $proprieteHabitats, 'profil' => $profil, 'form' => $proprieteForm->createView(),
        ]);
    }
    /**
     * @Route("internaute/mondomaine/{id}/activite", name="internaute_domaine_activite")
    */
    public function showActivityDomaine(int $id) {

        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $repository = $this->getDoctrine()->getRepository(Activite::class);
        $repository2 = $this->getDoctrine()->getRepository(Domaine::class);
        $domaine = $repository2->findBy([ 'idProprietaire' => $user]);
        $activite = $this->getDoctrine()->getRepository(Activite::class)->find($id);
        return $this->render('userinterface/activitedomaine/show.html.twig', [
            'controller_name' => 'ProfileController', 'activite' => $activite , 'profil' => $profil
        ]);
    }

    /**
     * @Route("internaute/activite/domaine/new", name="domaine_activite_new")
    */
    public function newActivityDomaine(Request $request){

        
        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $domaine = $this->getDoctrine()->getRepository(Domaine::class)->findOneBy([ 'idProprietaire' => $user ]);
        $activite = new Activite();
        $form = $this->createForm(ActiviteType::class, $activite);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $imageurl = $form->get('image')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('activite_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);
            $activite->setImage($fichier);
            $activite->setIdDomaine($domaine);
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($activite);
            $entityManager->flush();
            return $this->redirectToRoute('internaute_domaine');
        }
        
        return $this->render('userinterface/activitedomaine/new.html.twig', [
            'controller_name' => 'ProfileController' , 'profil' => $profil , 'form' => $form->createView()
        ]);
    }

    /**
     * @Route("internaute/activite/domaine/{id}/edit", name="domaine_activite_edit")
    */
    public function editActivityDomaine(Request $request , Activite $activite) {
        $user = $this->getUser()->getId();
        $profil = $this->getDoctrine()->getRepository(User::class)->find($user);
        $form = $this->createForm(ActiviteType::class, $activite);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $imageurl = $form->get('image')->getData();
            $fichier = md5(uniqid()) . '.' . $imageurl->guessExtension();
            $directory = $this->getParameter('activite_directory');
            $extension = $imageurl->guessExtension();
            $imageurl->move($directory, $fichier);
            $activite->setImage($fichier);
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($activite);
            $entityManager->flush();
            return $this->redirectToRoute('internaute_activite');
        }


        return $this->render('userinterface/activitedomaine/edit.html.twig', [
            'controller_name' => 'ProfileController', 'activite' => $activite , 'profil' => $profil , 'form' => $form->createView()
        ]);
    }

}
<file_sep><?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20210619134555 extends AbstractMigration
{
    public function getDescription() : string
    {
        return '';
    }

    public function up(Schema $schema) : void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE newsletter ADD region_id INT NOT NULL, ADD hebergement_id INT NOT NULL, DROP hebergement_prefere, DROP region');
        $this->addSql('ALTER TABLE newsletter ADD CONSTRAINT FK_7E8585C898260155 FOREIGN KEY (region_id) REFERENCES region (id)');
        $this->addSql('ALTER TABLE newsletter ADD CONSTRAINT FK_7E8585C823BB0F66 FOREIGN KEY (hebergement_id) REFERENCES type_habitat (id)');
        $this->addSql('CREATE INDEX IDX_7E8585C898260155 ON newsletter (region_id)');
        $this->addSql('CREATE INDEX IDX_7E8585C823BB0F66 ON newsletter (hebergement_id)');
        $this->addSql('ALTER TABLE user CHANGE url url VARCHAR(65535) NOT NULL');
    }

    public function down(Schema $schema) : void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE newsletter DROP FOREIGN KEY FK_7E8585C898260155');
        $this->addSql('ALTER TABLE newsletter DROP FOREIGN KEY FK_<KEY>');
        $this->addSql('DROP INDEX IDX_7E8585C898260155 ON newsletter');
        $this->addSql('DROP INDEX IDX_7E8585C823BB0F66 ON newsletter');
        $this->addSql('ALTER TABLE newsletter ADD hebergement_prefere VARCHAR(100) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, ADD region VARCHAR(200) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, DROP region_id, DROP hebergement_id');
        $this->addSql('ALTER TABLE user CHANGE url url MEDIUMTEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
    }
}
<file_sep><?php

namespace Tests\AppBundle\Entity;

use PHPUnit\Framework\TestCase;

class LocationTest extends TestCase
{

    public function testStatut()
    {

        $location = new Location(1, new \DateTime('now'),new \DateTime('now'));
        $this->assertSame("Validé", $location->setStatut("Validé"));
    }


}<file_sep><?php

namespace App\Controller;

use App\Entity\TypeHabitat;
use App\Form\TypeHabitat1Type;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("gerant/type/habitat")
 */
class TypeHabitatController extends AbstractController
{
    /**
     * @Route("/", name="type_habitat_index", methods={"GET"})
     */
    public function index(): Response
    {
        $typeHabitats = $this->getDoctrine()
            ->getRepository(TypeHabitat::class)
            ->findAll();

        return $this->render('type_habitat/index.html.twig', [
            'type_habitats' => $typeHabitats,
        ]);
    }

    /**
     * @Route("/new", name="type_habitat_new", methods={"GET","POST"})
     */
    public function new(Request $request): Response
    {
        $typeHabitat = new TypeHabitat();
        $form = $this->createForm(TypeHabitat1Type::class, $typeHabitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($typeHabitat);
            $entityManager->flush();

            return $this->redirectToRoute('type_habitat_index');
        }

        return $this->render('type_habitat/new.html.twig', [
            'type_habitat' => $typeHabitat,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="type_habitat_show", methods={"GET"})
     */
    public function show(TypeHabitat $typeHabitat): Response
    {
        return $this->render('type_habitat/show.html.twig', [
            'type_habitat' => $typeHabitat,
        ]);
    }

    /**
     * @Route("/{id}/edit", name="type_habitat_edit", methods={"GET","POST"})
     */
    public function edit(Request $request, TypeHabitat $typeHabitat): Response
    {
        $form = $this->createForm(TypeHabitat1Type::class, $typeHabitat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirectToRoute('type_habitat_index');
        }

        return $this->render('type_habitat/edit.html.twig', [
            'type_habitat' => $typeHabitat,
            'form' => $form->createView(),
        ]);
    }

    /**
     * @Route("/{id}", name="type_habitat_delete", methods={"DELETE"})
     */
    public function delete(Request $request, TypeHabitat $typeHabitat): Response
    {
        if ($this->isCsrfTokenValid('delete'.$typeHabitat->getId(), $request->request->get('_token'))) {
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($typeHabitat);
            $entityManager->flush();
        }

        return $this->redirectToRoute('type_habitat_index');
    }
}
<file_sep><?php

namespace App\Form;

use App\Entity\Activite;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;


class ActiviteType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('nom', TextType::class)
            ->add('image', FileType::class, array('data_class' => null))
            ->add('prix', MoneyType::class)
            ->add('adresse', TextType::class)
            ->add('description', TextareaType::class)
            ->add('ajouter' , SubmitType::class, [
                'attr' => ['class' => 'btn-edit-profile '],

            ])
        ;        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Activite::class,
        ]);
    }
}
<file_sep><?php

namespace App\Controller;

use App\Entity\Habitat;
use App\Entity\Region;
use App\Entity\Occupant;
use App\Entity\TypeHabitat;
use App\Entity\Coordonnees;
use App\Entity\Commentaire;
use App\Entity\PriseDeVue;
use App\Entity\Location;
use App\Entity\ActiviteHabitat;
use App\Form\CommentaireType;
use App\Form\OccupantType;
use App\Form\CoordonneesType;
use App\Form\Location1Type;
use App\Form\LocationOccupantType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use App\Repository\CommentaireRepository;
use App\Repository\PriseDeVueRepository;
use App\Repository\HabitatRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse ;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\Session\Session;



class ProductController extends AbstractController
{
    
    /**
     * @Route("/listHabitat", name="listHabitat")
     */
    public function liste(HabitatRepository $habitatRepository): Response
    {

        $user = $this->getUser();
        $typehabitats = $this->getDoctrine()->getRepository(TypeHabitat::class)->findAll();
        $liste = $this->getDoctrine()->getRepository(Habitat::class)->findAll();
        
        return $this->render('product/listeHabitat.html.twig', [
            'controller_name' => 'ProductController', 
            'habitats' => $liste, 'typehabitats' => $typehabitats

        ]);
    }

    /**
     * @Route("/listeRecherche/{habitat}/{region}/{capacite}", name="listeRecherche", methods={"POST","GET"})
     */
    public function listeRecherche(int $habitat , string $region , int $capacite): Response
    {

        $regionObj = $this->getDoctrine()->getRepository(Region::class)->findOneBy(['id' => 2 ]); 
        $liste = $this->getDoctrine()->getRepository(Habitat::class)->findBy(['idTypeHabitat' => $habitat , 'region' => $regionObj->getId() , 'capacite' => $capacite]);    
        return $this->render('product/listeHabitat.html.twig', [
            'controller_name' => 'ProductController', 
            'habitats' => $liste,

        ]);

    }
        /**
     * @Route("/failed", name="failed")
     */
    public function failed(): Response
    {


        $this->addFlash(
            'warning',
            'Your changes were saved!'
        );
        return $this->render('internaute.html.twig', [
            'controller_name' => 'StripeController',
        ]);
    }
    
    /**
     * @Route("/success", name="success")
     */
    public function success(): Response
    {

        $this->addFlash(
            'success',
            'Your changes were saved!'
        );

        return $this->render('internaute.html.twig', [
            'controller_name' => 'StripeController',
        ]);
    }
     /**
     * @Route("/product/{id}", name="product", methods={"GET","POST"})
     */
    public function product(int $id, CommentaireRepository $commentRepository, PriseDeVueRepository $prisedevueRepository, Request $request): Response
    {

        $habitats = $this->getDoctrine()->getRepository(Habitat::class)->find($id);
        $comments = $this->getDoctrine()->getRepository(Commentaire::class)->findBy(
            ['idHabitatIdCommentaire' => $habitats->getId() ],
            ['id' => 'DESC']
        );

        $photo = $this->getDoctrine()->getRepository(PriseDeVue::class)->findAll($id);
        $activite =  $this->getDoctrine()->getRepository(ActiviteHabitat::class)->findAll($id);
        $location = new Location();
        $user = $this->getUser();
        $location->setIdUserLocataire($user);
        $location->setIdHabitatIdLocation($habitats);
        $comment = new Commentaire();
        $comment->setIdUser($user);
        $comment->setIdHabitatIdCommentaire($habitats);
        $formComment = $this->createForm(CommentaireType::class, $comment);
        $formReservation = $this->createForm(Location1Type::class, $location);
        $formComment->handleRequest($request);
        if ($formComment->isSubmitted() && $formComment->isValid()) {

            $comment = $formComment->getData();
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($comment);
            $entityManager->flush();

            // ... do any other work - like sending them an email, etc
            // maybe set a "flash" success message for the user

            return $this->redirectToRoute('product' , array('id' => $id));

        }
        $formReservation->handleRequest($request);

        if ($formReservation->isSubmitted() && $formReservation->isValid()) {

            $location = $formReservation->getData();
            $comment = $formComment->getData();
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($location);
            $entityManager->flush();



// sets a HTTP response header

// prints the HTTP headers followed by the content
            return $this->redirectToRoute('reserver' , array('id' => $location->getId()));



            // ... do any other work - like sending them an email, etc
            // maybe set a "flash" success message for the user

    }

    
    return $this->render('product/index.html.twig', [
        'controller_name' => 'ProductController',
        'formComment' => $formComment->createView(),
        'formLocation' => $formReservation->createView(),
        'habitats' => $habitats,
        'comments' => $comments,
        'photos' => $photo,
        'activites' => $activite
    ]);
    }
    /**
     * @Route("/reserver/{id}", name="reserver", methods={"POST","GET"})
     */
    public function reserver(int $id): Response
    {

        $location = new Location();
        $depart = $this->get('session')->get('depart');
        $arrivee = $this->get('session')->get('arrivee');
        $nbpersonne = $this->get('session')->get('occupant');
        // dummy code - add some example tags to the task
        // (otherwise, the template will render an empty list of tags)
        // create 20 products! Bam!
        for ($i = 0; $i < $nbpersonne; $i++) {
            $occupants[$i] = new Occupant() ;
            $occupants[$i]->setType('Bébé');
            $location->getOccupants()->add($occupants[$i]);
        }
        $dateDifference = $arrivee->diff($depart);


        // end dummy code

        $form = $this->createForm(LocationOccupantType::class, $location);
        $request = Request::createFromGlobals();
        $form->handleRequest($request);


        $habitat= $this->getDoctrine()->getRepository(Habitat::class)->findOneBy(['id' => $id ]);
        $coordonnees= $this->createForm(CoordonneesType::class);
        $occupant= $this->createForm(OccupantType::class);

        if ($form->isSubmitted() && $form->isValid()) {
            

            $tabOccupants = $form->get('occupants')->getData();
            $nbOccupants = count($tabOccupants); 
            $prixttc = $habitat->getPrix() * $dateDifference->days ;
            $this->get('session')->set('infosOccupants', $tabOccupants);
            $this->get('session')->set('nbOccupants', $nbOccupants);
            $this->get('session')->set('prixTTC', $prixttc);
            return $this->redirectToRoute('coordonnees' , array('id' => $id ));


        }



        return $this->render('product/reserver.html.twig', [
            'controller_name' => 'ProductController', 
            'habitats' => $habitat,
            'form' => $form->createView(),
            'depart' => $depart,
            'arrivee' => $arrivee,
            'occupant' => $occupant->createView(),
            'nuits'=> $dateDifference,
        ]);
    }
    /**
     * @Route("/coordonnees/{id}", name="coordonnees", methods={"POST","GET"})
     */
    public function coordonnees(int $id): Response
    {
        $coordonnees = new Coordonnees(); 
        $form = $this->createForm(CoordonneesType::class, $coordonnees);
        $habitat= $this->getDoctrine()->getRepository(Habitat::class)->findOneBy(['id' => $id ]);
        $request = Request::createFromGlobals();
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            

            $tabOccupants = $form->getData();
            $this->get('session')->set('coordonnees', $coordonnees);
            return $this->redirectToRoute('payment' , array('id' => $id ));


        }
        return $this->render('coordonnees.html.twig', [
            'controller_name' => 'ProductController', 
            'habitats' => $habitat,
            'form' => $form->createView(),

        ]);

    }

    /**
     * @Route("/payment/{id}", name="payment", methods={"POST","GET"})
     */

     public function payment(int $id): Response {

        $habitat= $this->getDoctrine()->getRepository(Habitat::class)->findOneBy(['id' => $id ]);
        return $this->render('payments.html.twig', [
            'controller_name' => 'ProductController', 
            'habitats' => $habitat,

        ]);
     }
    /**
     * @Route("/create-checkout-session", name="checkout")
     */
    public function checkout(Request $request): JsonResponse
    {

        $request->request->all();
        
        \Stripe\Stripe::setApiKey('<KEY>');
        $session = \Stripe\Checkout\Session::create([
            'payment_method_types' => ['card'],
            'line_items' => [[
            'price_data' => [
            'currency' => 'eur',
            'unit_amount' => 12000,
            'product_data' => [
            'name' => 'Mobile Home de',
            'images' => ["public/images/userDefault.svg"],
            ],
            ],
            'quantity' => 1,
            ]],
            'mode' => 'payment',
            'success_url' => $this->generateUrl('internaute' , [], UrlGeneratorInterface::ABSOLUTE_URL),
             'cancel_url' => $this->generateUrl('internaute' , [], UrlGeneratorInterface::ABSOLUTE_URL),
            ]);

        return $response = new JsonResponse(['id' => $session->id ]);
    }

}
