src/Entity/MarketplaceCategory.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MarketplaceCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. /**
  12.  * @ORM\Entity(repositoryClass=MarketplaceCategoryRepository::class)
  13.  * @Vich\Uploadable
  14.  */
  15. class MarketplaceCategory
  16. {
  17.     const SPORT "Sport";
  18.     const SANTE "SantĂ©";
  19.     const ORGANISATION "Organisation";
  20.     const BIEN_ETRE "Bien-ĂȘtre";
  21.     const FAMILIES = [
  22.         self::SPORT => 1,
  23.         self::SANTE => 2,
  24.         self::ORGANISATION => 3,
  25.         self::BIEN_ETRE => 4,
  26.     ];
  27.     /**
  28.      * @ORM\Id
  29.      * @ORM\GeneratedValue
  30.      * @ORM\Column(type="integer")
  31.      */
  32.     private $id;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      */
  36.     private $name;
  37.     /**
  38.      * @ORM\Column(type="integer", nullable=true)
  39.      * @Assert\Choice(choices=self::FAMILIES)
  40.      */
  41.     private $family;
  42.     /**
  43.      * @ORM\Column(type="datetime")
  44.      * @Gedmo\Timestampable(on="create")
  45.      */
  46.     private $createdAt;
  47.     /**
  48.      * @ORM\Column(type="datetime", nullable=true)
  49.      * @Gedmo\Timestampable(on="update")
  50.      */
  51.     private $updatedAt;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=Workshop::class, mappedBy="marketplaceCategory")
  54.      */
  55.     private $workshops;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $image;
  60.     /**
  61.      * @Vich\UploadableField(mapping="marketplace_category_images", fileNameProperty="image")
  62.      * @Assert\File(
  63.      *     mimeTypes={"image/jpeg", "image/gif", "image/png"},
  64.      *     maxSize="700Ki",
  65.      * )
  66.      * @var File|null
  67.      */
  68.     private $imageFile;
  69.     /**
  70.      * @ORM\OneToMany(targetEntity=MarketplaceReservation::class, mappedBy="category")
  71.      */
  72.     private $marketplaceReservations;
  73.     /**
  74.      * @ORM\Column(type="string", length=255, nullable=true)
  75.      */
  76.     private $bannerImage;
  77.      /**
  78.      * @Vich\UploadableField(mapping="marketplace_category_images", fileNameProperty="bannerImage")
  79.      * @Assert\File(
  80.      *     mimeTypes={"image/jpeg", "image/gif", "image/png"},
  81.      *     maxSize="700Ki",
  82.      * )
  83.      * @var File|null
  84.      */
  85.     private $bannerImageFile;
  86.     /**
  87.      * @ORM\Column(type="text", nullable=true)
  88.      */
  89.     private $description;
  90.     public function __construct()
  91.     {
  92.         $this->workshops = new ArrayCollection();
  93.         $this->marketplaceReservations = new ArrayCollection();
  94.     }
  95.     public function getId(): ?int
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getName(): ?string
  100.     {
  101.         return $this->name;
  102.     }
  103.     public function setName(string $name): self
  104.     {
  105.         $this->name $name;
  106.         return $this;
  107.     }
  108.     public function getFamily(): ?int
  109.     {
  110.         return $this->family;
  111.     }
  112.     public function setFamily(?int $family): self
  113.     {
  114.         $this->family $family;
  115.         return $this;
  116.     }
  117.     public function getFamilyName(): ?string
  118.     {
  119.         return array_flip(self::FAMILIES)[$this->family];
  120.     }
  121.     public function getCreatedAt(): ?\DateTime
  122.     {
  123.         return $this->createdAt;
  124.     }
  125.     public function setCreatedAt(\DateTime $createdAt): self
  126.     {
  127.         $this->createdAt $createdAt;
  128.         return $this;
  129.     }
  130.     public function getUpdatedAt(): ?\DateTime
  131.     {
  132.         return $this->updatedAt;
  133.     }
  134.     public function setUpdatedAt(?\DateTime $updatedAt): self
  135.     {
  136.         $this->updatedAt $updatedAt;
  137.         return $this;
  138.     }
  139.     /**
  140.      * @return Collection<int, Workshop>
  141.      */
  142.     public function getWorkshops(): Collection
  143.     {
  144.         return $this->workshops;
  145.     }
  146.     public function addWorkshop(Workshop $workshop): self
  147.     {
  148.         if (!$this->workshops->contains($workshop)) {
  149.             $this->workshops[] = $workshop;
  150.             $workshop->setMarketplaceCategory($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeWorkshop(Workshop $workshop): self
  155.     {
  156.         if ($this->workshops->removeElement($workshop)) {
  157.             // set the owning side to null (unless already changed)
  158.             if ($workshop->getMarketplaceCategory() === $this) {
  159.                 $workshop->setMarketplaceCategory(null);
  160.             }
  161.         }
  162.         return $this;
  163.     }
  164.     public function getImage(): ?string
  165.     {
  166.         return $this->image;
  167.     }
  168.     public function setImage(?string $image): self
  169.     {
  170.         $this->image $image;
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return File|null
  175.      */
  176.     public function getImageFile(): ?File
  177.     {
  178.         return $this->imageFile;
  179.     }
  180.     /**
  181.      * @param File|null $imageFile
  182.      * @return MarketplaceCategory
  183.      */
  184.     public function setImageFile(?File $imageFile null): self
  185.     {
  186.         $this->imageFile $imageFile;
  187.         if ($imageFile) {
  188.             // if 'updatedAt' is not defined in your entity, use another property
  189.             $this->updatedAt = new \DateTime('now');
  190.         }
  191.         return $this;
  192.     }
  193.     /**
  194.      * @return Collection<int, MarketplaceReservation>
  195.      */
  196.     public function getMarketplaceReservations(): Collection
  197.     {
  198.         return $this->marketplaceReservations;
  199.     }
  200.     public function addMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
  201.     {
  202.         if (!$this->marketplaceReservations->contains($marketplaceReservation)) {
  203.             $this->marketplaceReservations[] = $marketplaceReservation;
  204.             $marketplaceReservation->setCategory($this);
  205.         }
  206.         return $this;
  207.     }
  208.     public function removeMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
  209.     {
  210.         if ($this->marketplaceReservations->removeElement($marketplaceReservation)) {
  211.             // set the owning side to null (unless already changed)
  212.             if ($marketplaceReservation->getCategory() === $this) {
  213.                 $marketplaceReservation->setCategory(null);
  214.             }
  215.         }
  216.         return $this;
  217.     }
  218.     public function getBannerImage(): ?string
  219.     {
  220.         return $this->bannerImage;
  221.     }
  222.     public function setBannerImage(?string $bannerImage): self
  223.     {
  224.         $this->bannerImage $bannerImage;
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return File|null
  229.      */
  230.     public function getBannerImageFile(): ?File
  231.     {
  232.         return $this->bannerImageFile;
  233.     }
  234.     /**
  235.      * @param File|null $bannerImageFile
  236.      * @return MarketplaceCategory
  237.      */
  238.     public function setBannerImageFile(?File $bannerImageFile null): self
  239.     {
  240.         $this->bannerImageFile $bannerImageFile;
  241.         if ($bannerImageFile) {
  242.             // if 'updatedAt' is not defined in your entity, use another property
  243.             $this->updatedAt = new \DateTime('now');
  244.         }
  245.         return $this;
  246.     }
  247.     public function getDescription(): ?string
  248.     {
  249.         return $this->description;
  250.     }
  251.     public function setDescription(?string $description): self
  252.     {
  253.         $this->description $description;
  254.         return $this;
  255.     }
  256. }