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:
@@ -4,14 +4,17 @@ namespace App\Doctor\Controller;
|
||||
|
||||
use App\Auth\Entity\User;
|
||||
use App\Auth\Repository\UserRepository;
|
||||
use App\Category\Repository\CategoryRepository;
|
||||
use App\DoctorService\Repository\DoctorServiceRepository;
|
||||
use App\Doctor\Entity\Doctor;
|
||||
use App\Doctor\Entity\DoctorAddress;
|
||||
use App\Doctor\Repository\DoctorAddressRepository;
|
||||
use App\Doctor\Repository\DoctorRepository;
|
||||
use App\Location\Repository\CityRepository;
|
||||
use App\Location\Repository\ProvinceRepository;
|
||||
use App\Shared\Constant\ErrorCodes;
|
||||
use App\Shared\Controller\BaseController;
|
||||
use App\Shared\Service\FileValidatorService;
|
||||
use App\Specialty\Repository\SpecialtyRepository;
|
||||
use OpenApi\Attributes as OA;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -25,7 +28,10 @@ class DoctorController extends BaseController
|
||||
public function __construct(
|
||||
private readonly DoctorRepository $doctorRepo,
|
||||
private readonly DoctorAddressRepository $addressRepo,
|
||||
private readonly CategoryRepository $categoryRepo,
|
||||
private readonly SpecialtyRepository $specialtyRepo,
|
||||
private readonly DoctorServiceRepository $serviceRepo,
|
||||
private readonly ProvinceRepository $provinceRepo,
|
||||
private readonly CityRepository $cityRepo,
|
||||
private readonly UserRepository $userRepo,
|
||||
private readonly FileValidatorService $fileValidator,
|
||||
private readonly string $projectDir,
|
||||
@@ -639,58 +645,41 @@ class DoctorController extends BaseController
|
||||
$doctor->setImages($data['images']);
|
||||
}
|
||||
|
||||
// Specialties (array of category IDs)
|
||||
// Specialties
|
||||
if (array_key_exists('specialties', $data) && is_array($data['specialties'])) {
|
||||
$doctor->getSpecialties()->clear();
|
||||
foreach ($data['specialties'] as $catId) {
|
||||
$cat = $this->categoryRepo->find((int) $catId);
|
||||
if ($cat !== null) {
|
||||
$doctor->getSpecialties()->add($cat);
|
||||
}
|
||||
foreach ($data['specialties'] as $id) {
|
||||
$s = $this->specialtyRepo->find((int) $id);
|
||||
if ($s !== null) $doctor->getSpecialties()->add($s);
|
||||
}
|
||||
}
|
||||
|
||||
// Expertise / doctor_services
|
||||
if (array_key_exists('doctor_services', $data) && is_array($data['doctor_services'])) {
|
||||
$doctor->getExpertise()->clear();
|
||||
foreach ($data['doctor_services'] as $catId) {
|
||||
$cat = is_numeric($catId)
|
||||
? $this->categoryRepo->find((int) $catId)
|
||||
: $this->categoryRepo->findOneBy(['label' => $catId, 'bundle' => 'doctor_services']);
|
||||
if ($cat !== null) {
|
||||
$doctor->getExpertise()->add($cat);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (array_key_exists('expertise', $data) && is_array($data['expertise'])) {
|
||||
$doctor->getExpertise()->clear();
|
||||
foreach ($data['expertise'] as $catId) {
|
||||
$cat = $this->categoryRepo->find((int) $catId);
|
||||
if ($cat !== null) {
|
||||
$doctor->getExpertise()->add($cat);
|
||||
}
|
||||
// Services (doctor_services / expertise)
|
||||
$servicesKey = array_key_exists('doctor_services', $data) ? 'doctor_services'
|
||||
: (array_key_exists('expertise', $data) ? 'expertise' : null);
|
||||
if ($servicesKey !== null && is_array($data[$servicesKey])) {
|
||||
$doctor->getServices()->clear();
|
||||
foreach ($data[$servicesKey] as $id) {
|
||||
$ds = $this->serviceRepo->find((int) $id);
|
||||
if ($ds !== null) $doctor->getServices()->add($ds);
|
||||
}
|
||||
}
|
||||
|
||||
// States
|
||||
// Provinces (states)
|
||||
if (array_key_exists('states', $data) && is_array($data['states'])) {
|
||||
$doctor->getStates()->clear();
|
||||
foreach ($data['states'] as $catId) {
|
||||
$cat = $this->categoryRepo->find((int) $catId);
|
||||
if ($cat !== null) {
|
||||
$doctor->getStates()->add($cat);
|
||||
}
|
||||
$doctor->getProvinces()->clear();
|
||||
foreach ($data['states'] as $id) {
|
||||
$p = $this->provinceRepo->find((int) $id);
|
||||
if ($p !== null) $doctor->getProvinces()->add($p);
|
||||
}
|
||||
}
|
||||
|
||||
// Cities
|
||||
if (array_key_exists('cities', $data) && is_array($data['cities'])) {
|
||||
$doctor->getCities()->clear();
|
||||
foreach ($data['cities'] as $catId) {
|
||||
$cat = $this->categoryRepo->find((int) $catId);
|
||||
if ($cat !== null) {
|
||||
$doctor->getCities()->add($cat);
|
||||
}
|
||||
foreach ($data['cities'] as $id) {
|
||||
$c = $this->cityRepo->find((int) $id);
|
||||
if ($c !== null) $doctor->getCities()->add($c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user