src/Flexy/Apps/BookingBundle/Entity/Offer.php line 13
<?php
namespace App\Flexy\Apps\BookingBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\Flexy\BookingBundle\Entity\OfferRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: OfferRepository::class)]
class Offer
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private ?string $name = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(type: 'float')]
private ?float $price = null;
#[ORM\Column(type: 'float', nullable: true)]
private ?float $oldPrice = null;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $endAt = null;
#[ORM\OneToMany(targetEntity: Reservation::class, mappedBy: 'offer')]
private \Doctrine\Common\Collections\Collection|array $reservations;
#[ORM\ManyToOne(targetEntity: CategoryOffer::class, inversedBy: 'offers')]
private ?\App\Flexy\Apps\BookingBundle\Entity\CategoryOffer $categoryOffer = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $image = null;
public function __construct()
{
$this->reservations = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
}
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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): self
{
$this->price = $price;
return $this;
}
public function getOldPrice(): ?float
{
return $this->oldPrice;
}
public function setOldPrice(?float $oldPrice): self
{
$this->oldPrice = $oldPrice;
return $this;
}
public function getEndAt(): ?\DateTimeImmutable
{
return $this->endAt;
}
public function setEndAt(?\DateTimeImmutable $endAt): self
{
$this->endAt = $endAt;
return $this;
}
/**
* @return Collection<int, Reservation>
*/
public function getReservations(): Collection
{
return $this->reservations;
}
public function addReservation(Reservation $reservation): self
{
if (!$this->reservations->contains($reservation)) {
$this->reservations[] = $reservation;
$reservation->setOffer($this);
}
return $this;
}
public function removeReservation(Reservation $reservation): self
{
if ($this->reservations->removeElement($reservation)) {
// set the owning side to null (unless already changed)
if ($reservation->getOffer() === $this) {
$reservation->setOffer(null);
}
}
return $this;
}
public function getCategoryOffer(): ?CategoryOffer
{
return $this->categoryOffer;
}
public function setCategoryOffer(?CategoryOffer $categoryOffer): self
{
$this->categoryOffer = $categoryOffer;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getFormattedPrice(){
return $this->getPrice() / 100 ;
}
}