feat: add insurance and location management

- Introduced InsuranceType enum for insurance categorization.
- Created InsuranceRepository for managing insurance entities.
- Developed LocationController for handling provinces and cities, including CRUD operations.
- Implemented City and Province entities with necessary fields and relationships.
- Added CityRepository and ProvinceRepository for database interactions.
- Established Specialty management with SpecialtyController, including CRUD operations.
- Created Specialty and Tag entities with appropriate fields and relationships.
- Implemented TagController for managing tags, including CRUD operations.
- Added TagRepository for database interactions with tags.
This commit is contained in:
hamed
2026-06-10 14:22:26 +03:30
parent 4b8504df91
commit 5066fcbd91
36 changed files with 2937 additions and 1241 deletions
+36 -40
View File
@@ -3,7 +3,10 @@
namespace App\Doctor\Entity;
use App\Auth\Entity\User;
use App\Category\Entity\Category;
use App\DoctorService\Entity\DoctorService;
use App\Location\Entity\City;
use App\Location\Entity\Province;
use App\Specialty\Entity\Specialty;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -72,35 +75,35 @@ class Doctor
#[ORM\Column(name: 'updated_at', type: 'integer')]
private int $updatedAt;
#[ORM\ManyToMany(targetEntity: Category::class)]
#[ORM\ManyToMany(targetEntity: Specialty::class)]
#[ORM\JoinTable(
name: 'doctor_specialties',
joinColumns: [new ORM\JoinColumn(name: 'doctor_id', referencedColumnName: 'id')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
inverseJoinColumns: [new ORM\JoinColumn(name: 'specialty_id', referencedColumnName: 'id')]
)]
private Collection $specialties;
#[ORM\ManyToMany(targetEntity: Category::class)]
#[ORM\ManyToMany(targetEntity: DoctorService::class)]
#[ORM\JoinTable(
name: 'doctor_expertise',
joinColumns: [new ORM\JoinColumn(name: 'doctor_id', referencedColumnName: 'id')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
inverseJoinColumns: [new ORM\JoinColumn(name: 'service_id', referencedColumnName: 'id')]
)]
private Collection $expertise;
private Collection $services;
#[ORM\ManyToMany(targetEntity: Category::class)]
#[ORM\ManyToMany(targetEntity: Province::class)]
#[ORM\JoinTable(
name: 'doctor_states',
name: 'doctor_provinces',
joinColumns: [new ORM\JoinColumn(name: 'doctor_id', referencedColumnName: 'id')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
inverseJoinColumns: [new ORM\JoinColumn(name: 'province_id', referencedColumnName: 'id')]
)]
private Collection $states;
private Collection $provinces;
#[ORM\ManyToMany(targetEntity: Category::class)]
#[ORM\ManyToMany(targetEntity: City::class)]
#[ORM\JoinTable(
name: 'doctor_cities',
joinColumns: [new ORM\JoinColumn(name: 'doctor_id', referencedColumnName: 'id')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
inverseJoinColumns: [new ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id')]
)]
private Collection $cities;
@@ -115,8 +118,8 @@ class Doctor
$this->createdAt = time();
$this->updatedAt = time();
$this->specialties = new ArrayCollection();
$this->expertise = new ArrayCollection();
$this->states = new ArrayCollection();
$this->services = new ArrayCollection();
$this->provinces = new ArrayCollection();
$this->cities = new ArrayCollection();
$this->addresses = new ArrayCollection();
}
@@ -139,8 +142,8 @@ class Doctor
public function getCreatedAt(): int { return $this->createdAt; }
public function getUpdatedAt(): int { return $this->updatedAt; }
public function getSpecialties(): Collection { return $this->specialties; }
public function getExpertise(): Collection { return $this->expertise; }
public function getStates(): Collection { return $this->states; }
public function getServices(): Collection { return $this->services; }
public function getProvinces(): Collection { return $this->provinces; }
public function getCities(): Collection { return $this->cities; }
public function getAddresses(): Collection { return $this->addresses; }
@@ -176,7 +179,9 @@ class Doctor
'gender' => $this->gender,
'degree' => $this->degree,
'img' => $this->images ?? [],
'specialties' => $this->formatCategories($this->specialties),
'specialties' => array_map(fn(Specialty $s) => [
'uuid' => $s->getUuid(), 'id' => (string) $s->getId(), 'name' => $s->getName(),
], $this->specialties->toArray()),
'satisfaction' => (string) $this->doctorRatePercentage,
'point' => (string) $this->doctorRate,
'free_turn' => 'نوبت آزادی موجود نیست',
@@ -197,36 +202,27 @@ class Doctor
'medical_system_code' => $this->medicalSystemCode,
'detail' => $this->info,
'degree' => $this->degree,
'specialties' => $this->formatCategories($this->specialties),
'specialties' => array_map(fn(Specialty $s) => [
'uuid' => $s->getUuid(), 'id' => (string) $s->getId(), 'name' => $s->getName(),
'parent_id' => $s->getParent()?->getId() !== null ? (string) $s->getParent()->getId() : null,
], $this->specialties->toArray()),
'img' => $this->images ?? [],
'expertise' => $this->formatCategories($this->expertise),
'expertise' => array_map(fn(DoctorService $ds) => [
'uuid' => $ds->getUuid(), 'id' => (string) $ds->getId(), 'name' => $ds->getName(),
], $this->services->toArray()),
'satisfaction' => (string) $this->doctorRatePercentage,
'point' => (string) $this->doctorRate,
'free_turn' => 'نوبت آزادی موجود نیست',
'hours_of_work' => 'برنامه کاری تنظیم نشده',
'address' => array_map(fn(DoctorAddress $a) => $a->toArray(), $this->addresses->toArray()),
'average_rate' => ['total_rates' => null],
'state' => $this->formatCategories($this->states),
'city' => $this->formatCategoriesWithParent($this->cities),
'state' => array_map(fn(Province $p) => [
'uuid' => $p->getUuid(), 'id' => (string) $p->getId(), 'name' => $p->getName(),
], $this->provinces->toArray()),
'city' => array_map(fn(City $c) => [
'uuid' => $c->getUuid(), 'id' => (string) $c->getId(), 'name' => $c->getName(),
'parent' => $c->getProvince() !== null ? (string) $c->getProvince()->getId() : null,
], $this->cities->toArray()),
];
}
private function formatCategories(Collection $collection): array
{
return array_map(fn(Category $c) => [
'uuid' => $c->getUuid(),
'id' => (string) $c->getId(),
'name' => $c->getLabel(),
], $collection->toArray());
}
private function formatCategoriesWithParent(Collection $collection): array
{
return array_map(fn(Category $c) => [
'uuid' => $c->getUuid(),
'id' => (string) $c->getId(),
'name' => $c->getLabel(),
'parent' => $c->getParentId() !== null ? (string) $c->getParentId() : null,
], $collection->toArray());
}
}