src/Entity/Salons/Salons.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Salons;
  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\Entity\User;
  8. use DateTimeImmutable;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Exception;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. use Symfony\Component\HttpFoundation\File\File;
  14. use Symfony\Component\HttpFoundation\File\UploadedFile;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  17. /**
  18.  * @ORM\Entity(repositoryClass="App\Repository\Salons\SalonsRepository")
  19.  * @UniqueEntity("name")
  20.  * @Vich\Uploadable
  21.  */
  22. class Salons
  23. {
  24.     use IdTrait;
  25.     use OrdreTrait;
  26.     use DatesTrait;
  27.     use SlugTrait;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      * @Assert\NotBlank(message="Veuillez saisir un nom")
  31.      */
  32.     private $name;
  33.     /**
  34.      * @ORM\Column(type="string", length=500, nullable=true)
  35.      */
  36.     private $extrait;
  37.     /**
  38.      * @ORM\Column(type="text", nullable=true)
  39.      */
  40.     private $content;
  41.     /**
  42.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  43.      *
  44.      * @Vich\UploadableField(mapping="salons_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="boolean")
  62.      */
  63.     private $online;
  64.     /**
  65.      * @ORM\Column(type="integer", nullable=true, options={"default": 0})
  66.      */
  67.     private $views;
  68.     /**
  69.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="salons")
  70.      */
  71.     private $user;
  72.     /**
  73.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  74.      */
  75.     private $updatedBy;
  76.     /**
  77.      * @ORM\ManyToOne(targetEntity="App\Entity\Salons\Categoriesalons", inversedBy="salons")
  78.      */
  79.     private $categories;
  80.     /**
  81.      * @ORM\OneToMany(targetEntity="App\Entity\Salons\Mediasalons", mappedBy="salons")
  82.      */
  83.     private $mediasalons;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      */
  87.     private $shortTitle;
  88.     /**
  89.      * @ORM\Column(type="string", length=255, nullable=true)
  90.      */
  91.     private $videoLink;
  92.     /**
  93.      * @ORM\Column(type="boolean")
  94.      */
  95.     private $nouveau;
  96.     /**
  97.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  98.      *
  99.      * @Vich\UploadableField(mapping="bandeau_cover", fileNameProperty="bandeaufile")
  100.      * @var File|null
  101.      * @Assert\Image(
  102.      *     mimeTypes={"image/jpeg", "image/png"},
  103.      *
  104.      *     maxHeight=230,
  105.      *     maxWidth=1920,
  106.      *     maxHeightMessage="Votre image doit faire 230 d'hauteur",
  107.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  108.      * )
  109.      */
  110.     private $imageBandeauFile;
  111.     /**
  112.      * @ORM\Column(type="string", length=255, nullable=true)
  113.      */
  114.     private $bandeaufile;
  115.     /**
  116.      * @ORM\Column(type="boolean")
  117.      */
  118.     private $featured;
  119.     public function getName(): ?string
  120.     {
  121.         return $this->name;
  122.     }
  123.     public function setName(string $name): self
  124.     {
  125.         $this->name $name;
  126.         return $this;
  127.     }
  128.     public function getExtrait(): ?string
  129.     {
  130.         return $this->extrait;
  131.     }
  132.     public function setExtrait(?string $extrait): self
  133.     {
  134.         $this->extrait $extrait;
  135.         return $this;
  136.     }
  137.     public function getContent(): ?string
  138.     {
  139.         return $this->content;
  140.     }
  141.     public function setContent(?string $content): self
  142.     {
  143.         $this->content $content;
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return File|null
  148.      */
  149.     public function getImageFile(): ?File
  150.     {
  151.         return $this->imageFile;
  152.     }
  153.     /**
  154.      * @param File|null $imageFile
  155.      * @return Salons
  156.      * @throws Exception
  157.      */
  158.     public function setImageFile(?File $imageFile): Salons
  159.     {
  160.         $this->imageFile $imageFile;
  161.         if ($this->imageFile instanceof UploadedFile) {
  162.             // It is required that at least one field changes if you are using doctrine
  163.             // otherwise the event listeners won't be called and the file is lost
  164.             $this->updatedAt = new DateTimeImmutable('now');
  165.         }
  166.         return $this;
  167.     }
  168.     public function getFilename(): ?string
  169.     {
  170.         return $this->filename;
  171.     }
  172.     public function setFilename(?string $filename): self
  173.     {
  174.         $this->filename $filename;
  175.         return $this;
  176.     }
  177.     public function getOnline(): ?bool
  178.     {
  179.         return $this->online;
  180.     }
  181.     public function setOnline(bool $online): self
  182.     {
  183.         $this->online $online;
  184.         return $this;
  185.     }
  186.     public function getViews(): ?int
  187.     {
  188.         return $this->views;
  189.     }
  190.     public function setViews(int $views): self
  191.     {
  192.         $this->views $views;
  193.         return $this;
  194.     }
  195.     public function getUser(): ?User
  196.     {
  197.         return $this->user;
  198.     }
  199.     public function setUser(?User $user): self
  200.     {
  201.         $this->user $user;
  202.         return $this;
  203.     }
  204.     public function getUpdatedBy(): ?User
  205.     {
  206.         return $this->updatedBy;
  207.     }
  208.     public function setUpdatedBy(?User $updatedBy): self
  209.     {
  210.         $this->updatedBy $updatedBy;
  211.         return $this;
  212.     }
  213.     public function getCategories(): ?Categoriesalons
  214.     {
  215.         return $this->categories;
  216.     }
  217.     public function setCategories(?Categoriesalons $categories): self
  218.     {
  219.         $this->categories $categories;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection|Mediasalons[]
  224.      */
  225.     public function getMediasalons(): Collection
  226.     {
  227.         return $this->mediasalons;
  228.     }
  229.     public function addMediasalon(Mediasalons $mediasalons): self
  230.     {
  231.         if (!$this->mediasalons->contains($mediasalons)) {
  232.             $this->mediasalons[] = $mediasalons;
  233.             $mediasalons->setSalons($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeMediasalon(Mediasalons $mediasalons): self
  238.     {
  239.         if ($this->mediasalons->contains($mediasalons)) {
  240.             $this->mediasalons->removeElement($mediasalons);
  241.             // set the owning side to null (unless already changed)
  242.             if ($mediasalons->getSalons() === $this) {
  243.                 $mediasalons->setSalons(null);
  244.             }
  245.         }
  246.         return $this;
  247.     }
  248.     public function getShortTitle(): ?string
  249.     {
  250.         return $this->shortTitle;
  251.     }
  252.     public function setShortTitle(?string $shortTitle): self
  253.     {
  254.         $this->shortTitle $shortTitle;
  255.         return $this;
  256.     }
  257.     public function getVideoLink(): ?string
  258.     {
  259.         return $this->videoLink;
  260.     }
  261.     public function setVideoLink(?string $videoLink): self
  262.     {
  263.         $this->videoLink $videoLink;
  264.         return $this;
  265.     }
  266.     public function getNouveau(): ?bool
  267.     {
  268.         return $this->nouveau;
  269.     }
  270.     public function setNouveau(bool $nouveau): self
  271.     {
  272.         $this->nouveau $nouveau;
  273.         return $this;
  274.     }
  275.     /**
  276.      * @return File|null
  277.      */
  278.     public function getImageBandeauFile(): ?File
  279.     {
  280.         return $this->imageBandeauFile;
  281.     }
  282.     /**
  283.      * @param File|null $imageBandeauFile
  284.      * @return Salons
  285.      */
  286.     public function setImageBandeauFile(?File $imageBandeauFile): Salons
  287.     {
  288.         $this->imageBandeauFile $imageBandeauFile;
  289.         if ($this->imageBandeauFile instanceof UploadedFile) {
  290.             // It is required that at least one field changes if you are using doctrine
  291.             // otherwise the event listeners won't be called and the file is lost
  292.             $this->updatedAt = new DateTimeImmutable('now');
  293.         }
  294.         return $this;
  295.     }
  296.     public function getBandeaufile(): ?string
  297.     {
  298.         return $this->bandeaufile;
  299.     }
  300.     public function setBandeaufile(?string $bandeaufile): self
  301.     {
  302.         $this->bandeaufile $bandeaufile;
  303.         return $this;
  304.     }
  305.     public function getFeatured(): ?bool
  306.     {
  307.         return $this->featured;
  308.     }
  309.     public function setFeatured(bool $featured): self
  310.     {
  311.         $this->featured $featured;
  312.         return $this;
  313.     }
  314. }