src/Flexy/BookingBundle/Entity/CategoryOffer.php line 13
<?php
namespace App\Flexy\BookingBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\Flexy\BookingBundle\Entity\CategoryOfferRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: CategoryOfferRepository::class)]
class CategoryOffer implements \Stringable
{
#[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\OneToMany(targetEntity: Offer::class, mappedBy: 'categoryOffer')]
private \Doctrine\Common\Collections\Collection|array $offers;
public function __construct()
{
$this->offers = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
}
public function __toString(): string
{
return (string) $this->name;
}
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;
}
/**
* @return Collection<int, Offer>
*/
public function getOffers(): Collection
{
return $this->offers;
}
public function addOffer(Offer $offer): self
{
if (!$this->offers->contains($offer)) {
$this->offers[] = $offer;
$offer->setCategoryOffer($this);
}
return $this;
}
public function removeOffer(Offer $offer): self
{
if ($this->offers->removeElement($offer)) {
// set the owning side to null (unless already changed)
if ($offer->getCategoryOffer() === $this) {
$offer->setCategoryOffer(null);
}
}
return $this;
}
}