<?php
namespace App\Controller;
use App\Repository\CountryRepository;
use App\Repository\HospitalRepository;
use App\Repository\StaffProfileRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{JsonResponse, Request};
use Symfony\Component\Routing\Annotation\Route;
#[Route(path: '/location'), IsGranted(data: 'IS_AUTHENTICATED_REMEMBERED')]
class LocationController extends AbstractController
{
#[Route(path: '/districts', name: 'location_district_json', methods: ['GET'])]
public function districts(Request $request, CountryRepository $countryRepo): JsonResponse
{
$stateId = $request->query->get('state_id');
$districts = $countryRepo->getDistricts($stateId);
return $this->json($districts);
}
#[Route(path: '/talukas', name: 'location_taluka_json', methods: ['GET'])]
public function talukas(Request $request, CountryRepository $countryRepo): JsonResponse
{
$districtId = $request->query->get('district_id');
$talukas = $countryRepo->getTalukas($districtId);
return $this->json($talukas);
}
#[Route(path: '/villages', name: 'location_village_json', methods: ['GET'])]
public function villages(Request $request, CountryRepository $countryRepo): JsonResponse
{
$talukaId = $request->query->get('taluka_id');
$villages = $countryRepo->getVillages($talukaId);
return $this->json($villages);
}
#[Route(path: '/type', name: 'hospital_list_by_type', methods: ['GET'])]
public function getHospitalByType(Request $request, HospitalRepository $hospitalRepo): JsonResponse
{
$centerType = $request->query->get('center_type');
$hospitalList = $hospitalRepo->getHospitalByCenterType($centerType);
return new JsonResponse($hospitalList);
}
#[Route(path: '/category', name: 'doctor_list_by_category', methods: ['GET'])]
public function getDoctorByCategory(Request $request, HospitalRepository $hospitalRepo): JsonResponse
{
$doctorCategory = $request->query->get('doctor_category');
$doctorList = $hospitalRepo->getDoctorListByCategory($doctorCategory);
return new JsonResponse($doctorList);
}
#[Route(path: '/getEmail', name: 'email_by_doctor', methods: ['GET'])]
public function getEmailByDoctor(Request $request, StaffProfileRepository $staffProfileRepo): JsonResponse
{
$doctorId = $request->query->get('doctor_category');
$getEmail = $staffProfileRepo->getEmailByDoctor($doctorId);
return new JsonResponse($getEmail);
}
}