src/Entity/Agencesvoyages/Agencesvoyages.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Agencesvoyages;
  3. use App\Entity\Common\DatesTrait;
  4. use App\Entity\Common\IdTrait;
  5. use App\Entity\Common\OrdreTrait;
  6. use App\Entity\Common\SlugTrait;
  7. use App\Repository\Agencesvoyages\AgencesvoyagesRepository;
  8. use DateTimeImmutable;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Exception;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use Symfony\Component\HttpFoundation\File\File;
  16. use Symfony\Component\HttpFoundation\File\UploadedFile;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  19. /**
  20.  * @ORM\Entity(repositoryClass=AgencesvoyagesRepository::class)
  21.  * @UniqueEntity("name")
  22.  * @Vich\Uploadable
  23.  */
  24. class Agencesvoyages
  25. {
  26.     use IdTrait;
  27.     use OrdreTrait;
  28.     use DatesTrait;
  29.     use SlugTrait;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      * @Assert\NotBlank(message="Veuillez saisir le nom pour l'agence")
  33.      */
  34.     private $name;
  35.     /**
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      */
  38.     private $extrait;
  39.     /**
  40.      * @ORM\Column(type="text", nullable=true)
  41.      */
  42.     private $description;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $email;
  47.     /**
  48.      * @ORM\Column(type="string", length=255, nullable=true)
  49.      */
  50.     private $contacts;
  51.     /**
  52.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  53.      *
  54.      * @Vich\UploadableField(mapping="agences_image", fileNameProperty="filename")
  55.      * @var File|null
  56.      * @Assert\Image(
  57.      *     mimeTypes={"image/jpeg", "image/png"},
  58.      *
  59.      *     maxHeight=1280,
  60.      *     maxWidth=1920,
  61.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  62.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  63.      * )
  64.      */
  65.     private $imageFile;
  66.     /**
  67.      * @ORM\Column(type="string", length=255, nullable=true)
  68.      */
  69.     private $filename;
  70.     /**
  71.      * @ORM\Column(type="boolean")
  72.      */
  73.     private $online;
  74.     /**
  75.      * @ORM\OneToMany(targetEntity=Mediasagencesvoyages::class, mappedBy="agencesvoyages")
  76.      */
  77.     private $mediasagencesvoyages;
  78.     public function __construct()
  79.     {
  80.         $this->mediasagencesvoyages = new ArrayCollection();
  81.     }
  82.     public function getName(): ?string
  83.     {
  84.         return $this->name;
  85.     }
  86.     public function setName(string $name): self
  87.     {
  88.         $this->name $name;
  89.         return $this;
  90.     }
  91.     public function getExtrait(): ?string
  92.     {
  93.         return $this->extrait;
  94.     }
  95.     public function setExtrait(?string $extrait): self
  96.     {
  97.         $this->extrait $extrait;
  98.         return $this;
  99.     }
  100.     public function getDescription(): ?string
  101.     {
  102.         return $this->description;
  103.     }
  104.     public function setDescription(?string $description): self
  105.     {
  106.         $this->description $description;
  107.         return $this;
  108.     }
  109.     public function getEmail(): ?string
  110.     {
  111.         return $this->email;
  112.     }
  113.     public function setEmail(?string $email): self
  114.     {
  115.         $this->email $email;
  116.         return $this;
  117.     }
  118.     public function getContacts(): ?string
  119.     {
  120.         return $this->contacts;
  121.     }
  122.     public function setContacts(?string $contacts): self
  123.     {
  124.         $this->contacts $contacts;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return File|null
  129.      */
  130.     public function getImageFile(): ?File
  131.     {
  132.         return $this->imageFile;
  133.     }
  134.     /**
  135.      * @param File|null $imageFile
  136.      * @return Agencesvoyages
  137.      * @throws Exception
  138.      */
  139.     public function setImageFile(?File $imageFile): Agencesvoyages
  140.     {
  141.         $this->imageFile $imageFile;
  142.         if ($this->imageFile instanceof UploadedFile) {
  143.             // It is required that at least one field changes if you are using doctrine
  144.             // otherwise the event listeners won't be called and the file is lost
  145.             $this->updatedAt = new DateTimeImmutable('now');
  146.         }
  147.         return $this;
  148.     }
  149.     public function getFilename(): ?string
  150.     {
  151.         return $this->filename;
  152.     }
  153.     public function setFilename(?string $filename): self
  154.     {
  155.         $this->filename $filename;
  156.         return $this;
  157.     }
  158.     public function getOnline(): ?bool
  159.     {
  160.         return $this->online;
  161.     }
  162.     public function setOnline(bool $online): self
  163.     {
  164.         $this->online $online;
  165.         return $this;
  166.     }
  167.     /**
  168.      * @return Collection|Mediasagencesvoyages[]
  169.      */
  170.     public function getMediasagencesvoyages(): Collection
  171.     {
  172.         return $this->mediasagencesvoyages;
  173.     }
  174.     public function addMediasagencesvoyage(Mediasagencesvoyages $mediasagencesvoyage): self
  175.     {
  176.         if (!$this->mediasagencesvoyages->contains($mediasagencesvoyage)) {
  177.             $this->mediasagencesvoyages[] = $mediasagencesvoyage;
  178.             $mediasagencesvoyage->setAgencesvoyages($this);
  179.         }
  180.         return $this;
  181.     }
  182.     public function removeMediasagencesvoyage(Mediasagencesvoyages $mediasagencesvoyage): self
  183.     {
  184.         if ($this->mediasagencesvoyages->contains($mediasagencesvoyage)) {
  185.             $this->mediasagencesvoyages->removeElement($mediasagencesvoyage);
  186.             // set the owning side to null (unless already changed)
  187.             if ($mediasagencesvoyage->getAgencesvoyages() === $this) {
  188.                 $mediasagencesvoyage->setAgencesvoyages(null);
  189.             }
  190.         }
  191.         return $this;
  192.     }
  193. }