src/Entity/Space.php line 17

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\SpaceRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. #[ORM\Entity(repositoryClassSpaceRepository::class)]
  12. #[ApiResource]
  13. #[Vich\Uploadable]
  14. class Space
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length65uniquetrue)]
  21.     private ?string $name null;
  22.     #[ORM\Column(length65uniquetrue)]
  23.     private ?string $slug null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     private ?string $description null;
  26.     // NOTE: This is not a mapped field of entity metadata, just a simple property.
  27.     #[Vich\UploadableField(mapping'spaces'fileNameProperty'imageName'size'imageSize')]
  28.     private ?File $imageFile null;
  29.     #[ORM\Column(nullabletrue)]
  30.     private ?string $imageName null;
  31.     #[ORM\Column(nullabletrue)]
  32.     private ?int $imageSize null;
  33.     #[ORM\OneToMany(mappedBy'space'targetEntityBooking::class)]
  34.     private Collection $bookings;
  35.     #[ORM\ManyToMany(targetEntitySpaceFeature::class, inversedBy'spaces'fetch'EAGER')]
  36.     private Collection $features;
  37.     #[ORM\Column]
  38.     private ?int $capacity null;
  39.     #[ORM\Column(nullabletrue)]
  40.     private ?float $pricePerHalfHour null;
  41.     #[ORM\Column(nullabletrue)]
  42.     private ?float $pricePerHour null;
  43.     #[ORM\Column(nullabletrue)]
  44.     private ?float $pricePerHalfDay null;
  45.     #[ORM\Column(nullabletrue)]
  46.     private ?float $pricePerDay null;
  47.     #[ORM\Column(nullabletrue)]
  48.     private ?float $pricePerEvening null;
  49.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  50.     private ?string $content null;
  51.     #[ORM\OneToMany(mappedBy'space'targetEntityLocalEvent::class, fetch'EAGER')]
  52.     private Collection $localEvents;
  53.     #[ORM\Column]
  54.     private ?\DateTimeImmutable $createdAt null;
  55.     #[ORM\Column(nullabletrue)]
  56.     private ?\DateTimeImmutable $updatedAt null;
  57.     #[ORM\Column(length145nullabletrue)]
  58.     private ?string $metaDescription null;
  59.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  60.     private ?string $contentDescription null;
  61.     public function __construct()
  62.     {
  63.         $this->bookings = new ArrayCollection();
  64.         $this->features = new ArrayCollection();
  65.         $this->localEvents = new ArrayCollection();
  66.     }
  67.     public function __toString(): string
  68.     {
  69.         return $this->getName();
  70.     }
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getName(): ?string
  76.     {
  77.         return $this->name;
  78.     }
  79.     public function setName(string $name): self
  80.     {
  81.         $this->name $name;
  82.         return $this;
  83.     }
  84.     public function getSlug(): ?string
  85.     {
  86.         return $this->slug;
  87.     }
  88.     public function setSlug(string $slug): self
  89.     {
  90.         $this->slug $slug;
  91.         return $this;
  92.     }
  93.     public function getDescription(): ?string
  94.     {
  95.         return $this->description;
  96.     }
  97.     public function setDescription(?string $description): self
  98.     {
  99.         $this->description $description;
  100.         return $this;
  101.     }
  102.     public function setImageFile(?File $imageFile null): void
  103.     {
  104.         $this->imageFile $imageFile;
  105.         if (null !== $imageFile) {
  106.             // It is required that at least one field changes if you are using doctrine
  107.             // otherwise the event listeners won't be called and the file is lost
  108.             $this->updatedAt = new \DateTimeImmutable();
  109.         }
  110.     }
  111.     public function getImageFile(): ?File
  112.     {
  113.         return $this->imageFile;
  114.     }
  115.     public function setImageName(?string $imageName): void
  116.     {
  117.         $this->imageName $imageName;
  118.     }
  119.     public function getImageName(): ?string
  120.     {
  121.         return $this->imageName;
  122.     }
  123.     public function setImageSize(?int $imageSize): void
  124.     {
  125.         $this->imageSize $imageSize;
  126.     }
  127.     public function getImageSize(): ?int
  128.     {
  129.         return $this->imageSize;
  130.     }
  131.     /**
  132.      * @return Collection<int, Booking>
  133.      */
  134.     public function getBookings(): Collection
  135.     {
  136.         return $this->bookings;
  137.     }
  138.     public function addBooking(Booking $booking): self
  139.     {
  140.         if (!$this->bookings->contains($booking)) {
  141.             $this->bookings->add($booking);
  142.             $booking->setSpace($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeBooking(Booking $booking): self
  147.     {
  148.         if ($this->bookings->removeElement($booking)) {
  149.             // set the owning side to null (unless already changed)
  150.             if ($booking->getSpace() === $this) {
  151.                 $booking->setSpace(null);
  152.             }
  153.         }
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return Collection<int, SpaceFeature>
  158.      */
  159.     public function getFeatures(): Collection
  160.     {
  161.         return $this->features;
  162.     }
  163.     public function addFeature(SpaceFeature $feature): self
  164.     {
  165.         if (!$this->features->contains($feature)) {
  166.             $this->features->add($feature);
  167.         }
  168.         return $this;
  169.     }
  170.     public function removeFeature(SpaceFeature $feature): self
  171.     {
  172.         $this->features->removeElement($feature);
  173.         return $this;
  174.     }
  175.     public function getCapacity(): ?int
  176.     {
  177.         return $this->capacity;
  178.     }
  179.     public function setCapacity(int $capacity): self
  180.     {
  181.         $this->capacity $capacity;
  182.         return $this;
  183.     }
  184.     public function getPricePerHalfHour(): ?float
  185.     {
  186.         return $this->pricePerHalfHour;
  187.     }
  188.     public function setPricePerHalfHour(?float $pricePerHalfHour): self
  189.     {
  190.         $this->pricePerHalfHour $pricePerHalfHour;
  191.         return $this;
  192.     }
  193.     public function getPricePerHour(): ?float
  194.     {
  195.         return $this->pricePerHour;
  196.     }
  197.     public function setPricePerHour(?float $pricePerHour): self
  198.     {
  199.         $this->pricePerHour $pricePerHour;
  200.         return $this;
  201.     }
  202.     public function getPricePerHalfDay(): ?float
  203.     {
  204.         return $this->pricePerHalfDay;
  205.     }
  206.     public function setPricePerHalfDay(?float $pricePerHalfDay): self
  207.     {
  208.         $this->pricePerHalfDay $pricePerHalfDay;
  209.         return $this;
  210.     }
  211.     public function getPricePerDay(): ?float
  212.     {
  213.         return $this->pricePerDay;
  214.     }
  215.     public function setPricePerDay(?float $pricePerDay): self
  216.     {
  217.         $this->pricePerDay $pricePerDay;
  218.         return $this;
  219.     }
  220.     public function getPricePerEvening(): ?float
  221.     {
  222.         return $this->pricePerEvening;
  223.     }
  224.     public function setPricePerEvening(?float $pricePerEvening): self
  225.     {
  226.         $this->pricePerEvening $pricePerEvening;
  227.         return $this;
  228.     }
  229.     public function getContent(): ?string
  230.     {
  231.         return $this->content;
  232.     }
  233.     public function setContent(?string $content): self
  234.     {
  235.         $this->content $content;
  236.         return $this;
  237.     }
  238.     /**
  239.      * @return Collection<int, LocalEvent>
  240.      */
  241.     public function getLocalEvents(): Collection
  242.     {
  243.         return $this->localEvents;
  244.     }
  245.     public function addLocalEvent(LocalEvent $localEvent): self
  246.     {
  247.         if (!$this->localEvents->contains($localEvent)) {
  248.             $this->localEvents->add($localEvent);
  249.             $localEvent->setSpace($this);
  250.         }
  251.         return $this;
  252.     }
  253.     public function removeLocalEvent(LocalEvent $localEvent): self
  254.     {
  255.         if ($this->localEvents->removeElement($localEvent)) {
  256.             // set the owning side to null (unless already changed)
  257.             if ($localEvent->getSpace() === $this) {
  258.                 $localEvent->setSpace(null);
  259.             }
  260.         }
  261.         return $this;
  262.     }
  263.     public function getCreatedAt(): ?\DateTimeImmutable
  264.     {
  265.         return $this->createdAt;
  266.     }
  267.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  268.     {
  269.         $this->createdAt $createdAt;
  270.         return $this;
  271.     }
  272.     public function getUpdatedAt(): ?\DateTimeImmutable
  273.     {
  274.         return $this->updatedAt;
  275.     }
  276.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  277.     {
  278.         $this->updatedAt $updatedAt;
  279.         return $this;
  280.     }
  281.     public function getMetaDescription(): ?string
  282.     {
  283.         return $this->metaDescription;
  284.     }
  285.     public function setMetaDescription(?string $metaDescription): self
  286.     {
  287.         $this->metaDescription $metaDescription;
  288.         return $this;
  289.     }
  290.     public function getContentDescription(): ?string
  291.     {
  292.         return $this->contentDescription;
  293.     }
  294.     public function setContentDescription(?string $contentDescription): self
  295.     {
  296.         $this->contentDescription $contentDescription;
  297.         return $this;
  298.     }
  299. }