src/Entity/Department.php line 16
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiResource;use App\Repository\DepartmentRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\UX\Turbo\Attribute\Broadcast;#[ORM\Entity(repositoryClass: DepartmentRepository::class)]#[ApiResource]#[Broadcast]class Department{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(type: Types::TEXT)]private ?string $description = null;#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'departments')]private ?self $parent = null;#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]private Collection $departments;#[ORM\ManyToOne(inversedBy: 'departments')]private ?Corporation $corporation = null;#[ORM\OneToMany(mappedBy: 'department', targetEntity: PortalAdministrator::class)]private Collection $portalAdministrators;public function __construct(){$this->departments = new ArrayCollection();$this->portalAdministrators = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function __toString(): string{return $this->getName();}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 getParent(): ?self{return $this->parent;}public function setParent(?self $parent): self{$this->parent = $parent;return $this;}/*** @return Collection<int, self>*/public function getDepartments(): Collection{return $this->departments;}public function addDepartment(self $department): self{if (!$this->departments->contains($department)) {$this->departments->add($department);$department->setParent($this);}return $this;}public function removeDepartment(self $department): self{if ($this->departments->removeElement($department)) {// set the owning side to null (unless already changed)if ($department->getParent() === $this) {$department->setParent(null);}}return $this;}public function getCorporation(): ?Corporation{return $this->corporation;}public function setCorporation(?Corporation $corporation): self{$this->corporation = $corporation;return $this;}/*** @return Collection<int, PortalAdministrator>*/public function getPortalAdministrators(): Collection{return $this->portalAdministrators;}public function addPortalAdministrator(PortalAdministrator $portalAdministrator): self{if (!$this->portalAdministrators->contains($portalAdministrator)) {$this->portalAdministrators->add($portalAdministrator);$portalAdministrator->setDepartment($this);}return $this;}public function removePortalAdministrator(PortalAdministrator $portalAdministrator): self{if ($this->portalAdministrators->removeElement($portalAdministrator)) {// set the owning side to null (unless already changed)if ($portalAdministrator->getDepartment() === $this) {$portalAdministrator->setDepartment(null);}}return $this;}}