<?phpnamespace App\Entity\Segmentation;use ApiPlatform\Metadata\ApiResource;use App\Repository\Segmentation\RegionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;/** * @ORM\Entity(repositoryClass=RegionRepository::class) */class Region{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=2) * @Groups({ * "Department:output", * }) */ private $code; /** * @ORM\Column(type="string", length=255) * @Groups({ * "Department:output", * }) */ private $name; /** * @ORM\OneToMany(targetEntity=Department::class, mappedBy="region") */ private $departments; public function __construct() { $this->departments = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getCode(): ?string { return $this->code; } public function setCode(string $code): self { $this->code = $code; return $this; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } /** * @return Collection<int, Department> */ public function getDepartments(): Collection { return $this->departments; } public function addDepartment(Department $department): self { if (!$this->departments->contains($department)) { $this->departments[] = $department; $department->setRegion($this); } return $this; } public function removeDepartment(Department $department): self { if ($this->departments->removeElement($department)) { // set the owning side to null (unless already changed) if ($department->getRegion() === $this) { $department->setRegion(null); } } return $this; }}