feat(doctor-address): add city and province associations to DoctorAddress entity

This commit is contained in:
hamed
2026-06-10 14:45:01 +03:30
parent ee1633a9d0
commit de702d78bd
5 changed files with 182 additions and 3 deletions
+23 -1
View File
@@ -2,6 +2,8 @@
namespace App\Doctor\Entity;
use App\Location\Entity\City;
use App\Location\Entity\Province;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
@@ -37,6 +39,14 @@ class DoctorAddress
#[ORM\Column(type: 'float', nullable: true)]
private ?float $longitude = null;
#[ORM\ManyToOne(targetEntity: City::class)]
#[ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?City $city = null;
#[ORM\ManyToOne(targetEntity: Province::class)]
#[ORM\JoinColumn(name: 'province_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?Province $province = null;
#[ORM\Column(name: 'created_at', type: 'integer')]
private int $createdAt;
@@ -57,14 +67,18 @@ class DoctorAddress
public function getName(): ?string { return $this->name; }
public function getAddress(): ?string { return $this->address; }
public function getTelephone(): ?string { return $this->telephone; }
public function getLatitude(): ?float { return $this->latitude; }
public function getLatitude(): ?float { return $this->latitude; }
public function getLongitude(): ?float { return $this->longitude; }
public function getCity(): ?City { return $this->city; }
public function getProvince(): ?Province { return $this->province; }
public function setName(?string $v): self { $this->name = $v; return $this; }
public function setAddress(?string $v): self { $this->address = $v; $this->touch(); return $this; }
public function setTelephone(?string $v): self { $this->telephone = $v; $this->touch(); return $this; }
public function setLatitude(?float $v): self { $this->latitude = $v; $this->touch(); return $this; }
public function setLongitude(?float $v): self { $this->longitude = $v; $this->touch(); return $this; }
public function setCity(?City $v): self { $this->city = $v; $this->touch(); return $this; }
public function setProvince(?Province $v): self { $this->province = $v; $this->touch(); return $this; }
private function touch(): void { $this->updatedAt = time(); }
@@ -80,6 +94,14 @@ class DoctorAddress
],
'address' => $this->address,
'telephone' => $this->telephone,
'city' => $this->city !== null ? [
'id' => (string) $this->city->getId(),
'name' => $this->city->getName(),
] : null,
'province' => $this->province !== null ? [
'id' => (string) $this->province->getId(),
'name' => $this->province->getName(),
] : null,
];
}
}