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