src/Entity/Advertisement.php line 24
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use App\Repository\AdvertisementRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;#[ApiResource(operations: [new GetCollection(normalizationContext: ['groups' => ['advertisement:list']]),new Get()],normalizationContext: ['groups' => ['advertisement:list', 'advertisement:view']])]#[ORM\Entity(repositoryClass: AdvertisementRepository::class)]class Advertisement{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['advertisement:list'])]private ?int $id = null;#[ORM\Column(length: 255)]#[Groups(['advertisement:list'])]private ?string $title = null;#[ORM\OneToMany(mappedBy: 'advertisement', targetEntity: AdvertisementAttachment::class, orphanRemoval: true)]private Collection $attachments;#[ORM\ManyToOne(inversedBy: 'advertisements')]#[ORM\JoinColumn(nullable: false)]private ?Establishment $establishment = null;public function __construct(){$this->attachments = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getTitle(): ?string{return $this->title;}public function setTitle(string $title): static{$this->title = $title;return $this;}/*** @return Collection<int, AdvertisementAttachment>*/public function getAttachments(): Collection{return $this->attachments;}public function addAttachment(AdvertisementAttachment $attachment): static{if (!$this->attachments->contains($attachment)) {$this->attachments->add($attachment);$attachment->setAdvertisement($this);}return $this;}public function removeAttachment(AdvertisementAttachment $attachment): static{if ($this->attachments->removeElement($attachment)) {// set the owning side to null (unless already changed)if ($attachment->getAdvertisement() === $this) {$attachment->setAdvertisement(null);}}return $this;}public function getEstablishment(): ?Establishment{return $this->establishment;}public function setEstablishment(?Establishment $establishment): static{$this->establishment = $establishment;return $this;}}