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
+35 -31
View File
@@ -3,8 +3,10 @@
namespace App\Clinic\Entity;
use App\Auth\Entity\User;
use App\Category\Entity\Category;
use App\Doctor\Entity\Doctor;
use App\DoctorService\Entity\DoctorService;
use App\Insurance\Entity\Insurance;
use App\Specialty\Entity\Specialty;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -14,7 +16,7 @@ use Symfony\Component\Uid\Uuid;
#[ORM\Table(name: 'clinics')]
#[ORM\Index(columns: ['user_id'], name: 'idx_clinics_owner')]
#[ORM\Index(columns: ['city_id'], name: 'idx_clinics_city')]
#[ORM\Index(columns: ['state_id'], name: 'idx_clinics_state')]
#[ORM\Index(columns: ['province_id'], name: 'idx_clinics_province')]
class Clinic
{
#[ORM\Id]
@@ -56,8 +58,8 @@ class Clinic
#[ORM\Column(name: 'city_id', type: 'integer', nullable: true)]
private ?int $cityId = null;
#[ORM\Column(name: 'state_id', type: 'integer', nullable: true)]
private ?int $stateId = null;
#[ORM\Column(name: 'province_id', type: 'integer', nullable: true)]
private ?int $provinceId = null;
#[ORM\Column(name: 'representation_id', type: 'integer', nullable: true)]
private ?int $representationId = null;
@@ -82,27 +84,27 @@ class Clinic
)]
private Collection $doctors;
#[ORM\ManyToMany(targetEntity: Category::class)]
#[ORM\ManyToMany(targetEntity: Specialty::class)]
#[ORM\JoinTable(
name: 'clinic_specialties',
joinColumns: [new ORM\JoinColumn(name: 'clinic_id', referencedColumnName: 'id', onDelete: 'CASCADE')],
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: 'clinic_services',
joinColumns: [new ORM\JoinColumn(name: 'clinic_id', referencedColumnName: 'id', onDelete: 'CASCADE')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
inverseJoinColumns: [new ORM\JoinColumn(name: 'service_id', referencedColumnName: 'id')]
)]
private Collection $services;
#[ORM\ManyToMany(targetEntity: Category::class)]
#[ORM\ManyToMany(targetEntity: Insurance::class)]
#[ORM\JoinTable(
name: 'clinic_insurances',
joinColumns: [new ORM\JoinColumn(name: 'clinic_id', referencedColumnName: 'id', onDelete: 'CASCADE')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id')]
inverseJoinColumns: [new ORM\JoinColumn(name: 'insurance_id', referencedColumnName: 'id')]
)]
private Collection $insurances;
@@ -130,10 +132,12 @@ class Clinic
public function getLatitude(): ?float { return $this->latitude; }
public function getLongitude(): ?float { return $this->longitude; }
public function getCityId(): ?int { return $this->cityId; }
public function getStateId(): ?int { return $this->stateId; }
public function getProvinceId(): ?int { return $this->provinceId; }
public function getRepresentationId(): ?int { return $this->representationId; }
public function getImagesClinic(): ?array { return $this->imagesClinic; }
public function getClinicLogo(): ?array { return $this->clinicLogo; }
public function getCreatedAt(): int { return $this->createdAt; }
public function getUpdatedAt(): int { return $this->updatedAt; }
public function getDoctors(): Collection { return $this->doctors; }
public function getSpecialties(): Collection { return $this->specialties; }
public function getServices(): Collection { return $this->services; }
@@ -148,23 +152,15 @@ class Clinic
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 setCityId(?int $v): self { $this->cityId = $v; $this->touch(); return $this; }
public function setStateId(?int $v): self { $this->stateId = $v; $this->touch(); return $this; }
public function setProvinceId(?int $v): self { $this->provinceId = $v; $this->touch(); return $this; }
public function setRepresentationId(?int $v): self { $this->representationId = $v; $this->touch(); return $this; }
public function setImagesClinic(?array $v): self { $this->imagesClinic = $v; $this->touch(); return $this; }
public function setClinicLogo(?array $v): self { $this->clinicLogo = $v; $this->touch(); return $this; }
private function touch(): void { $this->updatedAt = time(); }
public function toDetailArray(array $stateData = [], array $cityData = []): array
public function toDetailArray(array $provinceData = [], array $cityData = []): array
{
$formatCat = fn(Category $c) => [
'uuid' => $c->getUuid(), 'id' => (string) $c->getId(), 'name' => $c->getLabel(),
];
$formatCatWithParent = fn(Category $c) => [
'uuid' => $c->getUuid(), 'id' => (string) $c->getId(), 'name' => $c->getLabel(),
'parent' => $c->getParentId() !== null ? (string) $c->getParentId() : null,
];
return [
'id' => (string) $this->id,
'uuid' => $this->uuid,
@@ -173,14 +169,24 @@ class Clinic
'clinic_logo' => $this->clinicLogo ?? [],
'phone_number' => $this->telephone,
'caption' => $this->info,
'list_bime' => array_map($formatCat, $this->insurances->toArray()),
'specialties' => array_map($formatCatWithParent, $this->specialties->toArray()),
'services' => array_map($formatCat, $this->services->toArray()),
'clinic_specialty' => array_map($formatCatWithParent, $this->specialties->toArray()),
'list_bime' => array_map(fn(Insurance $i) => [
'uuid' => $i->getUuid(), 'id' => (string) $i->getId(), 'name' => $i->getName(),
], $this->insurances->toArray()),
'specialties' => array_map(fn(Specialty $s) => [
'uuid' => $s->getUuid(), 'id' => (string) $s->getId(), 'name' => $s->getName(),
'parent' => $s->getParent()?->getId() !== null ? (string) $s->getParent()->getId() : null,
], $this->specialties->toArray()),
'services' => array_map(fn(DoctorService $ds) => [
'uuid' => $ds->getUuid(), 'id' => (string) $ds->getId(), 'name' => $ds->getName(),
], $this->services->toArray()),
'clinic_specialty' => array_map(fn(Specialty $s) => [
'uuid' => $s->getUuid(), 'id' => (string) $s->getId(), 'name' => $s->getName(),
'parent' => $s->getParent()?->getId() !== null ? (string) $s->getParent()->getId() : null,
], $this->specialties->toArray()),
'doctors' => $this->doctors->count(),
'doctor_list' => null,
'city' => $cityData ? [$cityData] : [],
'state' => $stateData ? [$stateData] : [],
'state' => $provinceData ? [$provinceData] : [],
'location' => $this->address,
'map' => [
'latitude' => $this->latitude !== null ? (string) $this->latitude : null,
@@ -193,10 +199,6 @@ class Clinic
public function toListArray(): array
{
$formatCat = fn(Category $c) => [
'uuid' => $c->getUuid(), 'id' => (string) $c->getId(), 'name' => $c->getLabel(),
];
return [
'id' => (string) $this->id,
'uuid' => $this->uuid,
@@ -204,7 +206,9 @@ class Clinic
'images_clinic' => $this->imagesClinic ?? [],
'clinic_logo' => $this->clinicLogo ?? [],
'phone_number' => $this->telephone,
'specialties' => array_map($formatCat, $this->specialties->toArray()),
'specialties' => array_map(fn(Specialty $s) => [
'uuid' => $s->getUuid(), 'id' => (string) $s->getId(), 'name' => $s->getName(),
], $this->specialties->toArray()),
'doctors' => $this->doctors->count(),
'24_7' => $this->is247,
];