src/Entity/Salons/Categoriesalons.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Salons;
  3. use DateTime;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Mapping\Table;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Symfony\Component\HttpFoundation\File\File;
  12. use Symfony\Component\HttpFoundation\File\UploadedFile;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. /**
  16.  * @ORM\Entity(repositoryClass="App\Repository\Salons\CategoriesalonsRepository")
  17.  * @Table (name="categoriesalons")
  18.  * @UniqueEntity("name")
  19.  * @Vich\Uploadable
  20.  */
  21. class Categoriesalons
  22. {
  23.     /**
  24.      * @ORM\Id()
  25.      * @ORM\GeneratedValue()
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      * @Assert\NotBlank(message="Veuillez saisir le nom de la catégorie")
  32.      */
  33.     private $name;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      * @Gedmo\Slug(fields={"name"})
  37.      */
  38.     private $slug;
  39.     /**
  40.      * @ORM\Column(type="text", nullable=true)
  41.      */
  42.     private $description;
  43.     /**
  44.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  45.      *
  46.      * @Vich\UploadableField(mapping="categories_image", fileNameProperty="filename")
  47.      * @var File|null
  48.      * @Assert\Image(
  49.      *     mimeTypes={"image/jpeg", "image/png"},
  50.      *
  51.      *     maxHeight=250,
  52.      *     maxWidth=1920,
  53.      *     maxHeightMessage="Votre image doit faire 250 d'hauteur",
  54.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  55.      * )
  56.      */
  57.     private $imageFile;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $filename;
  62.     /**
  63.      * @ORM\Column(type="boolean")
  64.      */
  65.     private $online;
  66.     /**
  67.      * @var DateTime $updatedAt
  68.      * @ORM\Column(type="datetime", nullable=true)
  69.      *
  70.      * @Gedmo\Timestampable(on="update")
  71.      */
  72.     private $updatedAt;
  73.     /**
  74.      * @ORM\Column(type="integer")
  75.      */
  76.     private $ordre;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity="App\Entity\Salons\Salons", mappedBy="categories")
  79.      */
  80.     private $salons;
  81.     /**
  82.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  83.      *
  84.      * @Vich\UploadableField(mapping="categories_image", fileNameProperty="coverfile")
  85.      * @var File|null
  86.      * @Assert\Image(
  87.      *     mimeTypes={"image/jpeg", "image/png"},
  88.      *
  89.      *     maxHeight=1280,
  90.      *     maxWidth=1920,
  91.      *     maxHeightMessage="Votre image doit faire 1280 d'hauteur",
  92.      *     maxWidthMessage="Votre image doit faire 1920 de largeur"
  93.      * )
  94.      */
  95.     private $coverImageFile;
  96.     /**
  97.      * @ORM\Column(type="string", length=255, nullable=true)
  98.      */
  99.     private $coverfile;
  100.     public function __construct()
  101.     {
  102.         $this->salons = new ArrayCollection();
  103.     }
  104.     public function getId(): ?int
  105.     {
  106.         return $this->id;
  107.     }
  108.     public function getName(): ?string
  109.     {
  110.         return $this->name;
  111.     }
  112.     public function setName(string $name): self
  113.     {
  114.         $this->name $name;
  115.         return $this;
  116.     }
  117.     public function getSlug(): ?string
  118.     {
  119.         return $this->slug;
  120.     }
  121.     public function getDescription(): ?string
  122.     {
  123.         return $this->description;
  124.     }
  125.     public function setDescription(?string $description): self
  126.     {
  127.         $this->description $description;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return File|null
  132.      */
  133.     public function getImageFile(): ?File
  134.     {
  135.         return $this->imageFile;
  136.     }
  137.     /**
  138.      * @param File|null $imageFile
  139.      * @return Categoriesalons
  140.      * @throws \Exception
  141.      */
  142.     public function setImageFile(?File $imageFile): Categoriesalons
  143.     {
  144.         $this->imageFile $imageFile;
  145.         if ($this->imageFile instanceof UploadedFile) {
  146.             // It is required that at least one field changes if you are using doctrine
  147.             // otherwise the event listeners won't be called and the file is lost
  148.             $this->updatedAt = new DateTimeImmutable('now');
  149.         }
  150.         return $this;
  151.     }
  152.     public function getFilename(): ?string
  153.     {
  154.         return $this->filename;
  155.     }
  156.     public function setFilename(?string $filename): self
  157.     {
  158.         $this->filename $filename;
  159.         return $this;
  160.     }
  161.     public function getOnline(): ?bool
  162.     {
  163.         return $this->online;
  164.     }
  165.     public function setOnline(bool $online): self
  166.     {
  167.         $this->online $online;
  168.         return $this;
  169.     }
  170.     public function getUpdatedAt(): ?\DateTimeInterface
  171.     {
  172.         return $this->updatedAt;
  173.     }
  174.     public function getOrdre(): ?int
  175.     {
  176.         return $this->ordre;
  177.     }
  178.     public function setOrdre(int $ordre): self
  179.     {
  180.         $this->ordre $ordre;
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection|Salons[]
  185.      */
  186.     public function getSalons(): Collection
  187.     {
  188.         return $this->salons;
  189.     }
  190.     public function addSalon(Salons $salon): self
  191.     {
  192.         if (!$this->salons->contains($salon)) {
  193.             $this->salons[] = $salon;
  194.             $salon->setCategories($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeSalon(Salons $salon): self
  199.     {
  200.         if ($this->salons->contains($salon)) {
  201.             $this->salons->removeElement($salon);
  202.             // set the owning side to null (unless already changed)
  203.             if ($salon->getCategories() === $this) {
  204.                 $salon->setCategories(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     public function __toString()
  210.     {
  211.         return $this->name;
  212.     }
  213.     /**
  214.      * @return File|null
  215.      */
  216.     public function getCoverImageFile(): ?File
  217.     {
  218.         return $this->coverImageFile;
  219.     }
  220.     /**
  221.      * @param File|null $coverImageFile
  222.      * @return Categoriesalons
  223.      * @throws \Exception
  224.      */
  225.     public function setCoverImageFile(?File $coverImageFile): Categoriesalons
  226.     {
  227.         $this->coverImageFile $coverImageFile;
  228.         if ($this->coverImageFile instanceof UploadedFile) {
  229.             // It is required that at least one field changes if you are using doctrine
  230.             // otherwise the event listeners won't be called and the file is lost
  231.             $this->updatedAt = new DateTimeImmutable('now');
  232.         }
  233.         return $this;
  234.     }
  235.     public function getCoverfile(): ?string
  236.     {
  237.         return $this->coverfile;
  238.     }
  239.     public function setCoverfile(?string $coverfile): self
  240.     {
  241.         $this->coverfile $coverfile;
  242.         return $this;
  243.     }
  244. }