<?phpnamespace App\Entity;use App\Entity\Traits\TimeStampable;use App\Repository\MunicipalityRepository;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: MunicipalityRepository::class)]#[ORM\HasLifecycleCallbacks]class Municipality{ use TimeStampable; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private ?int $id = null; #[ORM\Column(type: 'string', length: 45)] private ?string $name; #[ORM\Column(type: 'decimal', precision: 10, scale: 8, nullable: true)] private ?string $latitude; #[ORM\Column(type: 'decimal', precision: 10, scale: 8, nullable: true)] private ?string $longitude; #[ORM\ManyToOne(inversedBy: 'municipalities')] private ?Prefecture $prefecture = null; #[ORM\ManyToOne] private ?User $CreatedBy = null; #[ORM\ManyToOne] private ?User $UpdatedBy = null; #[ORM\OneToMany(mappedBy: 'municipality', targetEntity: District::class)] private Collection $districts; public function __construct() { $this->createdAt = new DateTimeImmutable(); $this->updatedAt = new DateTimeImmutable(); $this->districts = new ArrayCollection(); } 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 getLatitude(): ?string { return $this->latitude; } public function setLatitude(?string $latitude): self { $this->latitude = $latitude; return $this; } public function getLongitude(): ?string { return $this->longitude; } public function setLongitude(?string $longitude): self { $this->longitude = $longitude; return $this; } public function getPrefecture(): ?Prefecture { return $this->prefecture; } public function setPrefecture(?Prefecture $prefecture): self { $this->prefecture = $prefecture; return $this; } public function getCreatedBy(): ?User { return $this->CreatedBy; } public function setCreatedBy(?User $CreatedBy): self { $this->CreatedBy = $CreatedBy; return $this; } public function getUpdatedBy(): ?User { return $this->UpdatedBy; } public function setUpdatedBy(?User $UpdatedBy): self { $this->UpdatedBy = $UpdatedBy; return $this; } public function getCreatedAt(): ?DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(DateTimeImmutable $createdAt): self { $this->createdAt = $createdAt; return $this; } // public function getUpdatedAt(): ?DateTimeImmutable // { // return $this->updatedAt; // } public function setUpdatedAt(?DateTimeImmutable $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function __toString() { return $this->name; } /** * @return Collection<int, District> */ public function getDistricts(): Collection { return $this->districts; } public function addDistrict(District $district): self { if (!$this->districts->contains($district)) { $this->districts->add($district); $district->setMunicipality($this); } return $this; } public function removeDistrict(District $district): self { if ($this->districts->removeElement($district)) { // set the owning side to null (unless already changed) if ($district->getMunicipality() === $this) { $district->setMunicipality(null); } } return $this; }}