src/Flexy/Apps/BookingBundle/Entity/CategoryOffer.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\CategoryOfferRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ApiResource]
  9. #[ORM\Entity(repositoryClassCategoryOfferRepository::class)]
  10. class CategoryOffer implements \Stringable
  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\OneToMany(targetEntityOffer::class, mappedBy'categoryOffer')]
  23.     private \Doctrine\Common\Collections\Collection|array $offers;
  24.     public function __construct()
  25.     {
  26.         $this->offers = new ArrayCollection();
  27.         $this->createdAt = new \DateTimeImmutable();
  28.     }
  29.     public function __toString(): string
  30.     {
  31.         return (string) $this->name;
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName(): ?string
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName(string $name): self
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getDescription(): ?string
  47.     {
  48.         return $this->description;
  49.     }
  50.     public function setDescription(?string $description): self
  51.     {
  52.         $this->description $description;
  53.         return $this;
  54.     }
  55.     public function getCreatedAt(): ?\DateTimeImmutable
  56.     {
  57.         return $this->createdAt;
  58.     }
  59.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  60.     {
  61.         $this->createdAt $createdAt;
  62.         return $this;
  63.     }
  64.     /**
  65.      * @return Collection<int, Offer>
  66.      */
  67.     public function getOffers(): Collection
  68.     {
  69.         return $this->offers;
  70.     }
  71.     public function addOffer(Offer $offer): self
  72.     {
  73.         if (!$this->offers->contains($offer)) {
  74.             $this->offers[] = $offer;
  75.             $offer->setCategoryOffer($this);
  76.         }
  77.         return $this;
  78.     }
  79.     public function removeOffer(Offer $offer): self
  80.     {
  81.         if ($this->offers->removeElement($offer)) {
  82.             // set the owning side to null (unless already changed)
  83.             if ($offer->getCategoryOffer() === $this) {
  84.                 $offer->setCategoryOffer(null);
  85.             }
  86.         }
  87.         return $this;
  88.     }
  89. }