src/Entity/Workshop.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WorkshopRepository;
  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 Symfony\Component\Validator\Constraints as Assert;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. /**
  12.  * @ORM\Entity(repositoryClass=WorkshopRepository::class)
  13.  * @Vich\Uploadable
  14.  */
  15. class Workshop
  16. {
  17.     const DELAY_TYPES = [
  18.         'days',
  19.         'hours'
  20.     ];
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue
  24.      * @ORM\Column(type="integer")
  25.      * @Groups({"workshop:read:id", "user_favorite:read", "event:read"})
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      * @Assert\NotBlank
  31.      * @Groups({"workshop:read:name", "user_favorite:read"})
  32.      */
  33.     private $name;
  34.     /**
  35.      * @ORM\Column(type="text")
  36.      * @Assert\NotBlank
  37.      * @Groups({"workshop:read:description", "user_favorite:read"})
  38.      */
  39.     private $description;
  40.     /**
  41.      * @ORM\Column(type="integer")
  42.      * @Assert\NotBlank
  43.      * @Groups({"workshop:read:duration", "user_favorite:read"})
  44.      */
  45.     private $duration;
  46.     /**
  47.      * @ORM\Column(type="integer", nullable=true)
  48.      * @Groups({"workshop:read:capacity", "user_favorite:read"})
  49.      */
  50.     private $capacity;
  51.     /**
  52.      * @ORM\Column(type="float", nullable=true)
  53.      * @Groups({"workshop:read:price", "user_favorite:read"})
  54.      */
  55.     private $price;
  56.     /**
  57.      * @ORM\Column(type="float", nullable=true)
  58.      * @Groups({"workshop:read:tva", "user_favorite:read"})
  59.      */
  60.     private $tva;
  61.     /**
  62.      * @ORM\Column(type="string", length=50)
  63.      * @Assert\NotBlank
  64.      */
  65.     private $color;
  66.     /**
  67.      * @ORM\Column(type="string", length=255)
  68.      * @Groups({"workshop:read:image", "user_favorite:read", "event:read"})
  69.      */
  70.     private $image;
  71.     /**
  72.      * @Groups({"workshop:read", "workshop:read:imageUrl", "event:read"})
  73.      * @var ?string
  74.      */
  75.     private $imageUrl "https://placehold.co/600x300";
  76.     /**
  77.      * @ORM\Column(type="datetime")
  78.      */
  79.     private $createdAt;
  80.     /**
  81.      * @ORM\Column(type="datetime", nullable=true)
  82.      */
  83.     private $updatedAt;
  84.     /**
  85.      * @ORM\ManyToOne(targetEntity=Tag::class)
  86.      * @ORM\JoinColumn(nullable=false)
  87.      * @Groups({"workshop:read:tag", "user_favorite:read", "event:read"})
  88.      */
  89.     private $tag;
  90.     /**
  91.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="workshops")
  92.      */
  93.     private $company;
  94.     /**
  95.      * @ORM\OneToMany(targetEntity=Event::class, mappedBy="workshop", orphanRemoval=true)
  96.      */
  97.     private $events;
  98.     /**
  99.      * @Vich\UploadableField(mapping="workshop_images", fileNameProperty="image")
  100.      * @Assert\File(
  101.      *     mimeTypes={"image/jpeg", "image/gif", "image/png"},
  102.      *     maxSize="700Ki",
  103.      * )
  104.      * @var File|null
  105.      */
  106.     private $imageFile;
  107.     /**
  108.      * @ORM\Column(type="string", length=50, nullable=true)
  109.      */
  110.     private $delay;
  111.     /**
  112.      * @ORM\Column(type="string", length=50, nullable=true)
  113.      */
  114.     private $delayType;
  115.     /**
  116.      * @ORM\ManyToOne(targetEntity=Specialist::class, inversedBy="workshops")
  117.      * @Groups({"workshop:read:specialist", "user_favorite:read"})
  118.      */
  119.     private $specialist;
  120.     /**
  121.      * @ORM\Column(type="float", nullable=true)
  122.      */
  123.     private $coefMajoration;
  124.     /**
  125.      * @ORM\Column(type="boolean", options={"default": 0})
  126.      * @Groups({"workshop:read:isFixedPrice", "user_favorite:read"})
  127.      */
  128.     private $isFixedPrice false;
  129.     /**
  130.      * @ORM\Column(type="float", nullable=true)
  131.      */
  132.     private $fixedPurchasePrice;
  133.     /**
  134.      * @ORM\Column(type="float", nullable=true)
  135.      * @Groups({"workshop:read:fixedSellingPrice", "user_favorite:read"})
  136.      */
  137.     private $fixedSellingPrice;
  138.     /**
  139.      * @ORM\Column(type="integer", nullable=true)
  140.      * @Groups({"workshop:read:marketplaceFamily", "user_favorite:read"})
  141.      */
  142.     private $marketplaceFamily;
  143.     /**
  144.      * @ORM\ManyToOne(targetEntity=MarketplaceCategory::class, inversedBy="workshops")
  145.      * @Groups({"workshop:read:marketplaceCategory", "user_favorite:read"})
  146.      */
  147.     private $marketplaceCategory;
  148.     /**
  149.      * @ORM\Column(type="boolean", options={"default": 0})
  150.      * @Groups({"workshop:read:marketplaceIsDisplay", "user_favorite:read"})
  151.      */
  152.     private $marketplaceIsDisplay false;
  153.     /**
  154.      * @ORM\Column(type="boolean", options={"default": 0})
  155.      * @Groups({"workshop:read:isVirtual", "user_favorite:read"})
  156.      */
  157.     private $isVirtual false;
  158.     /**
  159.      * @ORM\OneToMany(targetEntity=MarketplaceReservation::class, mappedBy="workshop")
  160.      */
  161.     private $marketplaceReservations;
  162.     /**
  163.      * @ORM\Column(type="string", length=255, nullable=true)
  164.      * @Groups({"workshop:read:bannerImage", "user_favorite:read"})
  165.      */
  166.     private $bannerImage;
  167.     /**
  168.      * @Vich\UploadableField(mapping="workshop_images", fileNameProperty="bannerImage")
  169.      * @Assert\File(
  170.      *     mimeTypes={"image/jpeg", "image/gif", "image/png"},
  171.      *     maxSize="700Ki",
  172.      * )
  173.      * @var File|null
  174.      */
  175.     private $bannerImageFile;
  176.     /**
  177.      * @ORM\Column(type="boolean", options={"default": 0})
  178.      * @Groups({"workshop:read:slottable"})
  179.      */
  180.     private $slottable false;
  181.     /**
  182.      * @ORM\Column(type="boolean", options={"default": 0})
  183.      * @Groups({"workshop:read:quotable"})
  184.      */
  185.     private $quotable false;
  186.     public $isFavorite false;
  187.     
  188.     /**
  189.      * @return File|null
  190.      */
  191.     public function getImageFile(): ?File
  192.     {
  193.         return $this->imageFile;
  194.     }
  195.     /**
  196.      * @param File|null $imageFile
  197.      * @return Workshop
  198.      */
  199.     public function setImageFile(?File $imageFile null): self
  200.     {
  201.         $this->imageFile $imageFile;
  202.         if ($imageFile) {
  203.             // if 'updatedAt' is not defined in your entity, use another property
  204.             $this->updatedAt = new \DateTime('now');
  205.         }
  206.         return $this;
  207.     }
  208.     /**
  209.      * @return File|null
  210.      */
  211.     public function getBannerImageFile(): ?File
  212.     {
  213.         return $this->bannerImageFile;
  214.     }
  215.     /**
  216.      * @param File|null $bannerImageFile
  217.      * @return Workshop
  218.      */
  219.     public function setBannerImageFile(?File $bannerImageFile null): self
  220.     {
  221.         $this->bannerImageFile $bannerImageFile;
  222.         if ($bannerImageFile) {
  223.             // if 'updatedAt' is not defined in your entity, use another property
  224.             $this->updatedAt = new \DateTime('now');
  225.         }
  226.         return $this;
  227.     }
  228.     public function __construct()
  229.     {
  230.         $this->events = new ArrayCollection();
  231.         $this->createdAt = new \DateTime();
  232.         $this->marketplaceReservations = new ArrayCollection();
  233.     }
  234.     public function getId(): ?int
  235.     {
  236.         return $this->id;
  237.     }
  238.     public function getName(): ?string
  239.     {
  240.         return $this->name;
  241.     }
  242.     public function setName(string $name): self
  243.     {
  244.         $this->name $name;
  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.     public function getDuration(): ?int
  257.     {
  258.         return $this->duration;
  259.     }
  260.     public function setDuration(int $duration): self
  261.     {
  262.         $this->duration $duration;
  263.         return $this;
  264.     }
  265.     public function getCapacity(): ?int
  266.     {
  267.         return $this->capacity;
  268.     }
  269.     public function setCapacity(int $capacity): self
  270.     {
  271.         $this->capacity $capacity;
  272.         return $this;
  273.     }
  274.     public function getPrice(): ?float
  275.     {
  276.         return $this->price;
  277.     }
  278.     public function setPrice(?float $price): self
  279.     {
  280.         $this->price $price;
  281.         return $this;
  282.     }
  283.     public function getTva(): ?float
  284.     {
  285.         return $this->tva;
  286.     }
  287.     public function setTva(?float $tva): self
  288.     {
  289.         $this->tva $tva;
  290.         return $this;
  291.     }
  292.     public function getColor(): ?string
  293.     {
  294.         return $this->color;
  295.     }
  296.     public function setColor(string $color): self
  297.     {
  298.         $this->color $color;
  299.         return $this;
  300.     }
  301.     public function getImage(): ?string
  302.     {
  303.         return $this->image;
  304.     }
  305.     public function setImage(?string $image): self
  306.     {
  307.         $this->image $image;
  308.         return $this;
  309.     }
  310.     public function getCreatedAt(): ?\DateTime
  311.     {
  312.         return $this->createdAt;
  313.     }
  314.     public function setCreatedAt(\DateTime $createdAt): self
  315.     {
  316.         $this->createdAt $createdAt;
  317.         return $this;
  318.     }
  319.     public function getUpdatedAt(): ?\DateTime
  320.     {
  321.         return $this->updatedAt;
  322.     }
  323.     public function setUpdatedAt(?\DateTime $updatedAt): self
  324.     {
  325.         $this->updatedAt $updatedAt;
  326.         return $this;
  327.     }
  328.     public function getTag(): ?Tag
  329.     {
  330.         return $this->tag;
  331.     }
  332.     public function setTag(?Tag $tag): self
  333.     {
  334.         $this->tag $tag;
  335.         return $this;
  336.     }
  337.     public function getCompany(): ?Company
  338.     {
  339.         return $this->company;
  340.     }
  341.     public function setCompany(?Company $company): self
  342.     {
  343.         $this->company $company;
  344.         return $this;
  345.     }
  346.     /**
  347.      * @return Collection|Event[]
  348.      */
  349.     public function getEvents(): Collection
  350.     {
  351.         return $this->events;
  352.     }
  353.     public function addEvent(Event $event): self
  354.     {
  355.         if (!$this->events->contains($event)) {
  356.             $this->events[] = $event;
  357.             $event->setWorkshop($this);
  358.         }
  359.         return $this;
  360.     }
  361.     public function removeEvent(Event $event): self
  362.     {
  363.         if ($this->events->removeElement($event)) {
  364.             // set the owning side to null (unless already changed)
  365.             if ($event->getWorkshop() === $this) {
  366.                 $event->setWorkshop(null);
  367.             }
  368.         }
  369.         return $this;
  370.     }
  371.     public function __toString()
  372.     {
  373.         $result $this->name " (max: $this->capacity)";
  374.         if ($this->company instanceof Company){
  375.             $result .= ' - ' strtoupper((string)$this->company);
  376.         }
  377.         if ($this->specialist instanceof Specialist){
  378.             $result .= ' - assurĂ© par ' $this->specialist;
  379.         }
  380.         return $result;
  381.     }
  382.     public function getDelay(): ?string
  383.     {
  384.         return $this->delay;
  385.     }
  386.     public function setDelay(?string $delay): self
  387.     {
  388.         $this->delay $delay;
  389.         return $this;
  390.     }
  391.     public function getDelayType(): ?string
  392.     {
  393.         return $this->delayType;
  394.     }
  395.     public function setDelayType(?string $delayType): self
  396.     {
  397.         $this->delayType $delayType;
  398.         return $this;
  399.     }
  400.     public function getSpecialist(): ?Specialist
  401.     {
  402.         return $this->specialist;
  403.     }
  404.     public function setSpecialist(?Specialist $specialist): self
  405.     {
  406.         $this->specialist $specialist;
  407.         return $this;
  408.     }
  409.     public function getCoefMajoration(): ?float
  410.     {
  411.         return $this->coefMajoration;
  412.     }
  413.     public function setCoefMajoration(?float $coefMajoration): self
  414.     {
  415.         $this->coefMajoration $coefMajoration;
  416.         return $this;
  417.     }
  418.     public function getIsFixedPrice(): ?bool
  419.     {
  420.         return $this->isFixedPrice;
  421.     }
  422.     public function setIsFixedPrice(bool $isFixedPrice): self
  423.     {
  424.         $this->isFixedPrice $isFixedPrice;
  425.         return $this;
  426.     }
  427.     public function getFixedPurchasePrice(): ?float
  428.     {
  429.         return $this->fixedPurchasePrice;
  430.     }
  431.     public function setFixedPurchasePrice(?float $fixedPurchasePrice): self
  432.     {
  433.         $this->fixedPurchasePrice $fixedPurchasePrice;
  434.         return $this;
  435.     }
  436.     public function getFixedSellingPrice(): ?float
  437.     {
  438.         return $this->fixedSellingPrice;
  439.     }
  440.     public function setFixedSellingPrice(?float $fixedSellingPrice): self
  441.     {
  442.         $this->fixedSellingPrice $fixedSellingPrice;
  443.         return $this;
  444.     }
  445.     public function getMarketplaceFamily(): ?int
  446.     {
  447.         return $this->marketplaceFamily;
  448.     }
  449.     public function setMarketplaceFamily(?int $marketplaceFamily): self
  450.     {
  451.         $this->marketplaceFamily $marketplaceFamily;
  452.         return $this;
  453.     }
  454.     public function getMarketplaceCategory(): ?MarketplaceCategory
  455.     {
  456.         return $this->marketplaceCategory;
  457.     }
  458.     public function setMarketplaceCategory(?MarketplaceCategory $marketplaceCategory): self
  459.     {
  460.         $this->marketplaceCategory $marketplaceCategory;
  461.         return $this;
  462.     }
  463.     public function getMarketplaceIsDisplay(): ?bool
  464.     {
  465.         return $this->marketplaceIsDisplay;
  466.     }
  467.     public function setMarketplaceIsDisplay(bool $marketplaceIsDisplay): self
  468.     {
  469.         $this->marketplaceIsDisplay $marketplaceIsDisplay;
  470.         return $this;
  471.     }
  472.     public function getIsVirtual(): ?bool
  473.     {
  474.         return $this->isVirtual;
  475.     }
  476.     public function setIsVirtual(?bool $isVirtual): self
  477.     {
  478.         $this->isVirtual $isVirtual;
  479.         return $this;
  480.     }
  481.     /**
  482.      * @return Collection<int, MarketplaceReservation>
  483.      */
  484.     public function getMarketplaceReservations(): Collection
  485.     {
  486.         return $this->marketplaceReservations;
  487.     }
  488.     public function addMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
  489.     {
  490.         if (!$this->marketplaceReservations->contains($marketplaceReservation)) {
  491.             $this->marketplaceReservations[] = $marketplaceReservation;
  492.             $marketplaceReservation->setWorkshop($this);
  493.         }
  494.         return $this;
  495.     }
  496.     public function removeMarketplaceReservation(MarketplaceReservation $marketplaceReservation): self
  497.     {
  498.         if ($this->marketplaceReservations->removeElement($marketplaceReservation)) {
  499.             // set the owning side to null (unless already changed)
  500.             if ($marketplaceReservation->getWorkshop() === $this) {
  501.                 $marketplaceReservation->setWorkshop(null);
  502.             }
  503.         }
  504.         return $this;
  505.     }
  506.     public function isFreeSellingPrice(): Bool
  507.     {
  508.         return (empty($this->fixedSellingPrice));
  509.     }
  510.     public function getBannerImage(): ?string
  511.     {
  512.         return $this->bannerImage;
  513.     }
  514.     public function setBannerImage(?string $bannerImage): self
  515.     {
  516.         $this->bannerImage $bannerImage;
  517.         return $this;
  518.     }
  519.     public function getImageUrl(): ?string
  520.     {
  521.         return $this->imageUrl;
  522.     }
  523.     public function setImageUrl(string $imageUrl): self
  524.     {
  525.         $this->imageUrl $imageUrl;
  526.         return $this;
  527.     }
  528.     public function getSlottable(): ?bool
  529.     {
  530.         return $this->slottable;
  531.     }
  532.     public function setSlottable(?bool $slottable): self
  533.     {
  534.         $this->slottable $slottable;
  535.         return $this;
  536.     }
  537.     public function getQuotable(): ?bool
  538.     {
  539.         return $this->quotable;
  540.     }
  541.     public function setQuotable(?bool $quotable): self
  542.     {
  543.         $this->quotable $quotable;
  544.         return $this;
  545.     }
  546. }