src/Flexy/Apps/BookingBundle/Entity/Offer.php line 13

  1. <?php
  2. namespace App\Flexy\Apps\BookingBundle\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Flexy\BookingBundle\Entity\OfferRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ApiResource]
  9. #[ORM\Entity(repositoryClassOfferRepository::class)]
  10. class Offer
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column(type'integer')]
  15.     private $id;
  16.     #[ORM\Column(type'string'length255)]
  17.     private ?string $name null;
  18.     #[ORM\Column(type'text'nullabletrue)]
  19.     private ?string $description null;
  20.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  21.     private ?\DateTimeImmutable $createdAt null;
  22.     #[ORM\Column(type'float')]
  23.     private ?float $price null;
  24.     #[ORM\Column(type'float'nullabletrue)]
  25.     private ?float $oldPrice null;
  26.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  27.     private ?\DateTimeImmutable $endAt null;
  28.     #[ORM\OneToMany(targetEntityReservation::class, mappedBy'offer')]
  29.     private \Doctrine\Common\Collections\Collection|array $reservations;
  30.     #[ORM\ManyToOne(targetEntityCategoryOffer::class, inversedBy'offers')]
  31.     private ?\App\Flexy\Apps\BookingBundle\Entity\CategoryOffer $categoryOffer null;
  32.     #[ORM\Column(type'string'length255nullabletrue)]
  33.     private ?string $image null;
  34.     public function __construct()
  35.     {
  36.         $this->reservations = new ArrayCollection();
  37.         $this->createdAt = new \DateTimeImmutable();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): self
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     public function getDescription(): ?string
  53.     {
  54.         return $this->description;
  55.     }
  56.     public function setDescription(?string $description): self
  57.     {
  58.         $this->description $description;
  59.         return $this;
  60.     }
  61.     public function getCreatedAt(): ?\DateTimeImmutable
  62.     {
  63.         return $this->createdAt;
  64.     }
  65.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  66.     {
  67.         $this->createdAt $createdAt;
  68.         return $this;
  69.     }
  70.     public function getPrice(): ?float
  71.     {
  72.         return $this->price;
  73.     }
  74.     public function setPrice(float $price): self
  75.     {
  76.         $this->price $price;
  77.         return $this;
  78.     }
  79.     public function getOldPrice(): ?float
  80.     {
  81.         return $this->oldPrice;
  82.     }
  83.     public function setOldPrice(?float $oldPrice): self
  84.     {
  85.         $this->oldPrice $oldPrice;
  86.         return $this;
  87.     }
  88.     public function getEndAt(): ?\DateTimeImmutable
  89.     {
  90.         return $this->endAt;
  91.     }
  92.     public function setEndAt(?\DateTimeImmutable $endAt): self
  93.     {
  94.         $this->endAt $endAt;
  95.         return $this;
  96.     }
  97.     /**
  98.      * @return Collection<int, Reservation>
  99.      */
  100.     public function getReservations(): Collection
  101.     {
  102.         return $this->reservations;
  103.     }
  104.     public function addReservation(Reservation $reservation): self
  105.     {
  106.         if (!$this->reservations->contains($reservation)) {
  107.             $this->reservations[] = $reservation;
  108.             $reservation->setOffer($this);
  109.         }
  110.         return $this;
  111.     }
  112.     public function removeReservation(Reservation $reservation): self
  113.     {
  114.         if ($this->reservations->removeElement($reservation)) {
  115.             // set the owning side to null (unless already changed)
  116.             if ($reservation->getOffer() === $this) {
  117.                 $reservation->setOffer(null);
  118.             }
  119.         }
  120.         return $this;
  121.     }
  122.     public function getCategoryOffer(): ?CategoryOffer
  123.     {
  124.         return $this->categoryOffer;
  125.     }
  126.     public function setCategoryOffer(?CategoryOffer $categoryOffer): self
  127.     {
  128.         $this->categoryOffer $categoryOffer;
  129.         return $this;
  130.     }
  131.     public function getImage(): ?string
  132.     {
  133.         return $this->image;
  134.     }
  135.     public function setImage(?string $image): self
  136.     {
  137.         $this->image $image;
  138.         return $this;
  139.     }
  140.     public function getFormattedPrice(){
  141.         return $this->getPrice() / 100 ;
  142.     }
  143. }