src/Entity/Space.php line 17
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\SpaceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: SpaceRepository::class)]
#[ApiResource]
#[Vich\Uploadable]
class Space
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 65, unique: true)]
private ?string $name = null;
#[ORM\Column(length: 65, unique: true)]
private ?string $slug = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $description = null;
// NOTE: This is not a mapped field of entity metadata, just a simple property.
#[Vich\UploadableField(mapping: 'spaces', fileNameProperty: 'imageName', size: 'imageSize')]
private ?File $imageFile = null;
#[ORM\Column(nullable: true)]
private ?string $imageName = null;
#[ORM\Column(nullable: true)]
private ?int $imageSize = null;
#[ORM\OneToMany(mappedBy: 'space', targetEntity: Booking::class)]
private Collection $bookings;
#[ORM\ManyToMany(targetEntity: SpaceFeature::class, inversedBy: 'spaces', fetch: 'EAGER')]
private Collection $features;
#[ORM\Column]
private ?int $capacity = null;
#[ORM\Column(nullable: true)]
private ?float $pricePerHalfHour = null;
#[ORM\Column(nullable: true)]
private ?float $pricePerHour = null;
#[ORM\Column(nullable: true)]
private ?float $pricePerHalfDay = null;
#[ORM\Column(nullable: true)]
private ?float $pricePerDay = null;
#[ORM\Column(nullable: true)]
private ?float $pricePerEvening = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $content = null;
#[ORM\OneToMany(mappedBy: 'space', targetEntity: LocalEvent::class, fetch: 'EAGER')]
private Collection $localEvents;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
#[ORM\Column(length: 145, nullable: true)]
private ?string $metaDescription = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $contentDescription = null;
public function __construct()
{
$this->bookings = new ArrayCollection();
$this->features = new ArrayCollection();
$this->localEvents = new ArrayCollection();
}
public function __toString(): string
{
return $this->getName();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function setImageName(?string $imageName): void
{
$this->imageName = $imageName;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageSize(?int $imageSize): void
{
$this->imageSize = $imageSize;
}
public function getImageSize(): ?int
{
return $this->imageSize;
}
/**
* @return Collection<int, Booking>
*/
public function getBookings(): Collection
{
return $this->bookings;
}
public function addBooking(Booking $booking): self
{
if (!$this->bookings->contains($booking)) {
$this->bookings->add($booking);
$booking->setSpace($this);
}
return $this;
}
public function removeBooking(Booking $booking): self
{
if ($this->bookings->removeElement($booking)) {
// set the owning side to null (unless already changed)
if ($booking->getSpace() === $this) {
$booking->setSpace(null);
}
}
return $this;
}
/**
* @return Collection<int, SpaceFeature>
*/
public function getFeatures(): Collection
{
return $this->features;
}
public function addFeature(SpaceFeature $feature): self
{
if (!$this->features->contains($feature)) {
$this->features->add($feature);
}
return $this;
}
public function removeFeature(SpaceFeature $feature): self
{
$this->features->removeElement($feature);
return $this;
}
public function getCapacity(): ?int
{
return $this->capacity;
}
public function setCapacity(int $capacity): self
{
$this->capacity = $capacity;
return $this;
}
public function getPricePerHalfHour(): ?float
{
return $this->pricePerHalfHour;
}
public function setPricePerHalfHour(?float $pricePerHalfHour): self
{
$this->pricePerHalfHour = $pricePerHalfHour;
return $this;
}
public function getPricePerHour(): ?float
{
return $this->pricePerHour;
}
public function setPricePerHour(?float $pricePerHour): self
{
$this->pricePerHour = $pricePerHour;
return $this;
}
public function getPricePerHalfDay(): ?float
{
return $this->pricePerHalfDay;
}
public function setPricePerHalfDay(?float $pricePerHalfDay): self
{
$this->pricePerHalfDay = $pricePerHalfDay;
return $this;
}
public function getPricePerDay(): ?float
{
return $this->pricePerDay;
}
public function setPricePerDay(?float $pricePerDay): self
{
$this->pricePerDay = $pricePerDay;
return $this;
}
public function getPricePerEvening(): ?float
{
return $this->pricePerEvening;
}
public function setPricePerEvening(?float $pricePerEvening): self
{
$this->pricePerEvening = $pricePerEvening;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
/**
* @return Collection<int, LocalEvent>
*/
public function getLocalEvents(): Collection
{
return $this->localEvents;
}
public function addLocalEvent(LocalEvent $localEvent): self
{
if (!$this->localEvents->contains($localEvent)) {
$this->localEvents->add($localEvent);
$localEvent->setSpace($this);
}
return $this;
}
public function removeLocalEvent(LocalEvent $localEvent): self
{
if ($this->localEvents->removeElement($localEvent)) {
// set the owning side to null (unless already changed)
if ($localEvent->getSpace() === $this) {
$localEvent->setSpace(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getContentDescription(): ?string
{
return $this->contentDescription;
}
public function setContentDescription(?string $contentDescription): self
{
$this->contentDescription = $contentDescription;
return $this;
}
}