<?phpnamespace App\Entity;use App\Repository\RegionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=RegionRepository::class) * @ORM\HasLifecycleCallbacks() */class Region{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="text", nullable=true) */ private $description; /** * @ORM\ManyToOne(targetEntity=Country::class, inversedBy="regions") * @ORM\JoinColumn(nullable=false) */ private $country; /** * @ORM\Column(type="datetime", nullable=true) */ private $updateAt; /** * @ORM\OneToMany(targetEntity=Department::class, mappedBy="region") */ private $departments; public function __construct() { $this->departments = new ArrayCollection(); $this->setUpdateAt(new \DateTime()); } 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 getCountry(): ?Country { return $this->country; } public function setCountry(?Country $country): self { $this->country = $country; return $this; } public function getUpdateAt(): ?\DateTimeInterface { return $this->updateAt; } public function setUpdateAt(?\DateTimeInterface $updateAt): self { $this->updateAt = $updateAt; return $this; } /** * @return Collection|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->contains($department)) { $this->departments->removeElement($department); // set the owning side to null (unless already changed) if ($department->getRegion() === $this) { $department->setRegion(null); } } return $this; } public function __toString() { return $this->getName(); } /** * @ORM\PreUpdate */ public function updateDate() { $this->setUpdateAt(new \DateTime()); }}