src/Entity/Hotels/Hotels.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Hotels;
  3. use App\Entity\Localizations\Cities;
  4. use App\Entity\Common\DatesTrait;
  5. use App\Entity\Common\IdTrait;
  6. use App\Entity\Common\OrdreTrait;
  7. use App\Entity\Common\SlugTrait;
  8. use App\Entity\Typechambres;
  9. use App\Entity\User;
  10. use DateTime;
  11. use DateTimeImmutable;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Exception;
  16. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  17. use Symfony\Component\HttpFoundation\File\File;
  18. use Symfony\Component\HttpFoundation\File\UploadedFile;
  19. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. /**
  22.  * @ORM\Entity(repositoryClass="App\Repository\Hotels\HotelsRepository")
  23.  * @UniqueEntity("name")
  24.  * @Vich\Uploadable
  25.  */
  26. class Hotels
  27. {
  28.     use IdTrait;
  29.     use OrdreTrait;
  30.     use DatesTrait;
  31.     use SlugTrait;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      * @Assert\NotBlank(message="Veuillez saisir le nom de votre hôtel")
  35.      */
  36.     private $name;
  37.     /**
  38.      * @ORM\Column(type="text", nullable=true)
  39.      */
  40.     private $description;
  41.     /**
  42.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  43.      *
  44.      * @Vich\UploadableField(mapping="hotels_image", fileNameProperty="filename")
  45.      * @var File|null
  46.      * @Assert\Image(
  47.      *     mimeTypes={"image/jpeg", "image/png"},
  48.      *
  49.      *     maxHeight=1280,
  50.      *     maxWidth=1920,
  51.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  52.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  53.      * )
  54.      */
  55.     private $imageFile;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $filename;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     private $address;
  64.     /**
  65.      * @ORM\Column(type="integer", options={"default": 0})
  66.      * @Assert\NotBlank(message="Veuillez saisir le nombre d'étoile")
  67.      */
  68.     private $standing;
  69.     /**
  70.      * @ORM\Column(type="string", length=255)
  71.      * @Assert\NotBlank(message="Veuillez saisir un email")
  72.      * @Assert\Email(message="Veuillez saisir un email valide")
  73.      */
  74.     private $email;
  75.     /**
  76.      * @ORM\Column(type="string", length=255, nullable=true)
  77.      */
  78.     private $contacts;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      */
  82.     private $siteweb;
  83.     /**
  84.      * @ORM\Column(type="string", length=255, nullable=true)
  85.      */
  86.     private $facebook;
  87.     /**
  88.      * @ORM\Column(type="string", length=255, nullable=true)
  89.      */
  90.     private $instagram;
  91.     /**
  92.      * @ORM\Column(type="string", length=255, nullable=true)
  93.      */
  94.     private $twitter;
  95.     /**
  96.      * @ORM\Column(type="integer", options={"default": 0})
  97.      * @Assert\NotBlank(message="Veuillez saisir le nombre total de chambre svp!")
  98.      */
  99.     private $totalchambres;
  100.     /**
  101.      * @ORM\Column(type="boolean", options={"default": 0})
  102.      */
  103.     private $online;
  104.     /**
  105.      * @ORM\Column(type="boolean", options={"default": 0})
  106.      */
  107.     private $activated;
  108.     /**
  109.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="hotels")
  110.      */
  111.     private $user;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity="App\Entity\Hotels\Mediashotels", mappedBy="hotels")
  114.      */
  115.     private $mediashotels;
  116.     /**
  117.      * @ORM\OneToMany(targetEntity="App\Entity\Hotels\Annonceshotels", mappedBy="hotels")
  118.      */
  119.     private $annonceshotels;
  120.     /**
  121.      * @ORM\ManyToMany(targetEntity="App\Entity\Hotels\Commodites", inversedBy="hotels")
  122.      */
  123.     private $commodites;
  124.     /**
  125.      * @ORM\Column(type="string", length=100, nullable=true)
  126.      */
  127.     private $longitude;
  128.     /**
  129.      * @ORM\Column(type="string", length=100, nullable=true)
  130.      */
  131.     private $latitude;
  132.     /**
  133.      * @ORM\Column(type="string", length=500, nullable=true)
  134.      */
  135.     private $otherscommodites;
  136.     /**
  137.      * @ORM\Column(type="string", length=255, nullable=true)
  138.      */
  139.     private $superficie;
  140.     /**
  141.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  142.      *
  143.      * @Vich\UploadableField(mapping="hotels_image", fileNameProperty="bandeaufile")
  144.      * @var File|null
  145.      * @Assert\Image(
  146.      *     mimeTypes={"image/jpeg", "image/png"},
  147.      *
  148.      *     maxHeight=710,
  149.      *     maxWidth=1920,
  150.      *     maxHeightMessage="Votre image doit faire 710 d'hauteur",
  151.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  152.      * )
  153.      */
  154.     private $bandeauImageFile;
  155.     /**
  156.      * @ORM\Column(type="string", length=255, nullable=true)
  157.      */
  158.     private $bandeaufile;
  159.     /**
  160.      * @ORM\ManyToOne(targetEntity="App\Entity\Localizations\Cities", inversedBy="hotels")
  161.      */
  162.     private $cities;
  163.     /**
  164.      * @ORM\ManyToMany(targetEntity="App\Entity\Typechambres", inversedBy="hotels")
  165.      */
  166.     private $typechambres;
  167.     /**
  168.      * @ORM\Column(type="boolean")
  169.      */
  170.     private $featured;
  171.     public function __construct()
  172.     {
  173.         $this->commodites = new ArrayCollection();
  174.         $this->typechambres = new ArrayCollection();
  175.     }
  176.     public function getName(): ?string
  177.     {
  178.         return $this->name;
  179.     }
  180.     public function setName(string $name): self
  181.     {
  182.         $this->name $name;
  183.         return $this;
  184.     }
  185.     public function getDescription(): ?string
  186.     {
  187.         return $this->description;
  188.     }
  189.     public function setDescription(?string $description): self
  190.     {
  191.         $this->description $description;
  192.         return $this;
  193.     }
  194.     /**
  195.      * @return File|null
  196.      */
  197.     public function getImageFile(): ?File
  198.     {
  199.         return $this->imageFile;
  200.     }
  201.     /**
  202.      * @param File|null $imageFile
  203.      * @return Hotels
  204.      * @throws Exception
  205.      */
  206.     public function setImageFile(?File $imageFile): Hotels
  207.     {
  208.         $this->imageFile $imageFile;
  209.         if ($this->imageFile instanceof UploadedFile) {
  210.             // It is required that at least one field changes if you are using doctrine
  211.             // otherwise the event listeners won't be called and the file is lost
  212.             $this->updatedAt = new DateTimeImmutable('now');
  213.         }
  214.         return $this;
  215.     }
  216.     public function getFilename(): ?string
  217.     {
  218.         return $this->filename;
  219.     }
  220.     public function setFilename(?string $filename): self
  221.     {
  222.         $this->filename $filename;
  223.         return $this;
  224.     }
  225.     public function getAddress(): ?string
  226.     {
  227.         return $this->address;
  228.     }
  229.     public function setAddress(?string $address): self
  230.     {
  231.         $this->address $address;
  232.         return $this;
  233.     }
  234.     public function getStanding(): ?int
  235.     {
  236.         return $this->standing;
  237.     }
  238.     public function setStanding(int $standing): self
  239.     {
  240.         $this->standing $standing;
  241.         return $this;
  242.     }
  243.     public function getEmail(): ?string
  244.     {
  245.         return $this->email;
  246.     }
  247.     public function setEmail(string $email): self
  248.     {
  249.         $this->email $email;
  250.         return $this;
  251.     }
  252.     public function getContacts(): ?string
  253.     {
  254.         return $this->contacts;
  255.     }
  256.     public function setContacts(?string $contacts): self
  257.     {
  258.         $this->contacts $contacts;
  259.         return $this;
  260.     }
  261.     public function getSiteweb(): ?string
  262.     {
  263.         return $this->siteweb;
  264.     }
  265.     public function setSiteweb(?string $siteweb): self
  266.     {
  267.         $this->siteweb $siteweb;
  268.         return $this;
  269.     }
  270.     public function getFacebook(): ?string
  271.     {
  272.         return $this->facebook;
  273.     }
  274.     public function setFacebook(?string $facebook): self
  275.     {
  276.         $this->facebook $facebook;
  277.         return $this;
  278.     }
  279.     public function getInstagram(): ?string
  280.     {
  281.         return $this->instagram;
  282.     }
  283.     public function setInstagram(?string $instagram): self
  284.     {
  285.         $this->instagram $instagram;
  286.         return $this;
  287.     }
  288.     public function getTwitter(): ?string
  289.     {
  290.         return $this->twitter;
  291.     }
  292.     public function setTwitter(?string $twitter): self
  293.     {
  294.         $this->twitter $twitter;
  295.         return $this;
  296.     }
  297.     public function getTotalchambres(): ?int
  298.     {
  299.         return $this->totalchambres;
  300.     }
  301.     public function setTotalchambres(int $totalchambres): self
  302.     {
  303.         $this->totalchambres $totalchambres;
  304.         return $this;
  305.     }
  306.     public function getOnline(): ?bool
  307.     {
  308.         return $this->online;
  309.     }
  310.     public function setOnline(bool $online): self
  311.     {
  312.         $this->online $online;
  313.         return $this;
  314.     }
  315.     public function getActivated(): ?bool
  316.     {
  317.         return $this->activated;
  318.     }
  319.     public function setActivated(bool $activated): self
  320.     {
  321.         $this->activated $activated;
  322.         return $this;
  323.     }
  324.     public function getUser(): ?User
  325.     {
  326.         return $this->user;
  327.     }
  328.     public function setUser(?User $user): self
  329.     {
  330.         $this->user $user;
  331.         return $this;
  332.     }
  333.     /**
  334.      * @return Collection|Mediashotels[]
  335.      */
  336.     public function getMediashotels(): Collection
  337.     {
  338.         return $this->mediashotels;
  339.     }
  340.     public function addMediashotel(Mediashotels $mediashotels): self
  341.     {
  342.         if (!$this->mediashotels->contains($mediashotels)) {
  343.             $this->mediashotels[] = $mediashotels;
  344.             $mediashotels->setHotels($this);
  345.         }
  346.         return $this;
  347.     }
  348.     public function removeMediashotel(Mediashotels $mediashotels): self
  349.     {
  350.         if ($this->mediashotels->contains($mediashotels)) {
  351.             $this->mediashotels->removeElement($mediashotels);
  352.             // set the owning side to null (unless already changed)
  353.             if ($mediashotels->getHotels() === $this) {
  354.                 $mediashotels->setHotels(null);
  355.             }
  356.         }
  357.         return $this;
  358.     }
  359.     /**
  360.      * @return Collection|Annonceshotels[]
  361.      */
  362.     public function getAnnonceshotels(): Collection
  363.     {
  364.         return $this->annonceshotels;
  365.     }
  366.     public function addAnnonceshotel(Annonceshotels $annonceshotels): self
  367.     {
  368.         if (!$this->annonceshotels->contains($annonceshotels)) {
  369.             $this->annonceshotels[] = $annonceshotels;
  370.             $annonceshotels->setHotels($this);
  371.         }
  372.         return $this;
  373.     }
  374.     public function removeAnnonceshotel(Annonceshotels $annonceshotels): self
  375.     {
  376.         if ($this->annonceshotels->contains($annonceshotels)) {
  377.             $this->annonceshotels->removeElement($annonceshotels);
  378.             // set the owning side to null (unless already changed)
  379.             if ($annonceshotels->getHotels() === $this) {
  380.                 $annonceshotels->setHotels(null);
  381.             }
  382.         }
  383.         return $this;
  384.     }
  385.     public function __toString()
  386.     {
  387.         return $this->name;
  388.     }
  389.     /**
  390.      * @return Collection|Commodites[]
  391.      */
  392.     public function getCommodites(): Collection
  393.     {
  394.         return $this->commodites;
  395.     }
  396.     public function addCommodite(Commodites $commodite): self
  397.     {
  398.         if (!$this->commodites->contains($commodite)) {
  399.             $this->commodites[] = $commodite;
  400.             $commodite->addHotel($this);
  401.         }
  402.         return $this;
  403.     }
  404.     public function removeCommodite(Commodites $commodite): self
  405.     {
  406.         if ($this->commodites->contains($commodite)) {
  407.             $this->commodites->removeElement($commodite);
  408.             $commodite->removeHotel($this);
  409.         }
  410.         return $this;
  411.     }
  412.     public function getLongitude(): ?string
  413.     {
  414.         return $this->longitude;
  415.     }
  416.     public function setLongitude(?string $longitude): self
  417.     {
  418.         $this->longitude $longitude;
  419.         return $this;
  420.     }
  421.     public function getLatitude(): ?string
  422.     {
  423.         return $this->latitude;
  424.     }
  425.     public function setLatitude(?string $latitude): self
  426.     {
  427.         $this->latitude $latitude;
  428.         return $this;
  429.     }
  430.     public function getOtherscommodites(): ?string
  431.     {
  432.         return $this->otherscommodites;
  433.     }
  434.     public function setOtherscommodites(?string $otherscommodites): self
  435.     {
  436.         $this->otherscommodites $otherscommodites;
  437.         return $this;
  438.     }
  439.     public function getSuperficie(): ?string
  440.     {
  441.         return $this->superficie;
  442.     }
  443.     public function setSuperficie(?string $superficie): self
  444.     {
  445.         $this->superficie $superficie;
  446.         return $this;
  447.     }
  448.     /**
  449.      * @return File|null
  450.      */
  451.     public function getBandeauImageFile(): ?File
  452.     {
  453.         return $this->bandeauImageFile;
  454.     }
  455.     /**
  456.      * @param File|null $bandeauImageFile
  457.      * @return Hotels
  458.      * @throws Exception
  459.      */
  460.     public function setBandeauImageFile(?File $bandeauImageFile): Hotels
  461.     {
  462.         $this->bandeauImageFile $bandeauImageFile;
  463.         if ($this->bandeauImageFile instanceof UploadedFile) {
  464.             // It is required that at least one field changes if you are using doctrine
  465.             // otherwise the event listeners won't be called and the file is lost
  466.             $this->updatedAt = new DateTimeImmutable('now');
  467.         }
  468.         return $this;
  469.     }
  470.     public function getBandeaufile(): ?string
  471.     {
  472.         return $this->bandeaufile;
  473.     }
  474.     public function setBandeaufile(?string $bandeaufile): self
  475.     {
  476.         $this->bandeaufile $bandeaufile;
  477.         return $this;
  478.     }
  479.     public function getCities(): ?Cities
  480.     {
  481.         return $this->cities;
  482.     }
  483.     public function setCities(?Cities $cities): self
  484.     {
  485.         $this->cities $cities;
  486.         return $this;
  487.     }
  488.     /**
  489.      * @return Collection|Typechambres[]
  490.      */
  491.     public function getTypechambres(): Collection
  492.     {
  493.         return $this->typechambres;
  494.     }
  495.     public function addTypechambre(Typechambres $typechambre): self
  496.     {
  497.         if (!$this->typechambres->contains($typechambre)) {
  498.             $this->typechambres[] = $typechambre;
  499.         }
  500.         return $this;
  501.     }
  502.     public function removeTypechambre(Typechambres $typechambre): self
  503.     {
  504.         if ($this->typechambres->contains($typechambre)) {
  505.             $this->typechambres->removeElement($typechambre);
  506.         }
  507.         return $this;
  508.     }
  509.     public function getFeatured(): ?bool
  510.     {
  511.         return $this->featured;
  512.     }
  513.     public function setFeatured(bool $featured): self
  514.     {
  515.         $this->featured $featured;
  516.         return $this;
  517.     }
  518. }