← Back
Editing: ReportItem.php
<?php namespace App\Entity; use App\Enum\ReportType; use App\Repository\ReportItemRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\SerializedName; #[ORM\Entity(repositoryClass: ReportItemRepository::class)] class ReportItem { #[Groups(['show_report_item', 'show_report'])] #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[Groups(['show_report_item', 'show_report'])] #[ORM\Column(length: 255)] private ?string $label = null; #[Groups(['show_report_item', 'show_report'])] #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'reportItems')] private ?self $parent = null; #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)] private Collection $reportItems; #[Groups(['show_report_item', 'show_report'])] #[ORM\Column(type: 'string', length: 30, enumType: ReportType::class)] private ?ReportType $type = null; #[ORM\OneToMany(mappedBy: 'reportItem', targetEntity: Report::class)] private Collection $reports; public function __construct() { $this->reportItems = new ArrayCollection(); $this->reports = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function setId(int $id): self { $this->id = $id; return $this; } public function getLabel(): ?string { return $this->label; } public function setLabel(string $label): self { $this->label = $label; return $this; } public function getParent(): ?self { return $this->parent; } public function setParent(?self $parent): self { $this->parent = $parent; return $this; } /** * @return Collection<int, self> */ public function getReportItems(): Collection { return $this->reportItems; } public function addReportItem(self $reportItem): self { if (!$this->reportItems->contains($reportItem)) { $this->reportItems->add($reportItem); $reportItem->setParent($this); } return $this; } public function removeReportItem(self $reportItem): self { if ($this->reportItems->removeElement($reportItem)) { // set the owning side to null (unless already changed) if ($reportItem->getParent() === $this) { $reportItem->setParent(null); } } return $this; } public function getType(): ?ReportType { return $this->type; } public function setType(ReportType $type): self { $this->type = $type; return $this; } /** * @return Collection<int, Report> */ public function getReports(): Collection { return $this->reports; } public function addReport(Report $report): self { if (!$this->reports->contains($report)) { $this->reports->add($report); $report->setReportItem($this); } return $this; } public function removeReport(Report $report): self { if ($this->reports->removeElement($report)) { // set the owning side to null (unless already changed) if ($report->getReportItem() === $this) { $report->setReportItem(null); } } return $this; } #[Groups(['show_report_item', 'show_report'])] #[SerializedName('hasChildren')] public function hasChildren(): bool { return $this->reportItems->count() > 0; } public function __toString() { return $this->getLabel(); } }
Save File
Cancel