diff --git a/Modules/Linksehat/Http/Controllers/Api/SearchController.php b/Modules/Linksehat/Http/Controllers/Api/SearchController.php index 1bf284fe..7baa2eec 100644 --- a/Modules/Linksehat/Http/Controllers/Api/SearchController.php +++ b/Modules/Linksehat/Http/Controllers/Api/SearchController.php @@ -43,10 +43,12 @@ class SearchController extends Controller ->when($request->lat && $request->lng, function (EloquentBuilder $query) use ($request) { $query->getQuery() ->selectRaw("organizations.id, organizations.name, addresses.text AS address, cities.name AS city_name, 6371 * acos (cos ( radians($request->lat) ) * cos( radians( addresses.lat ) ) * cos( radians( addresses.lng ) - radians($request->lng) ) + sin ( radians($request->lat) ) * sin( radians( addresses.lat ) )) as distance") + ->groupBy(['organizations.id', 'organizations.name', 'addresses.text', 'practitioner_roles.organization_id', 'practitioner_roles.speciality_id', 'addresses.lat', 'addresses.lng', 'cities.name']) ->orderBy('distance', 'ASC'); }, function (EloquentBuilder $query) { $query->getQuery() ->select(['organizations.id', 'organizations.name', 'addresses.text AS address', 'cities.name AS city_name']) + ->groupBy(['organizations.id', 'organizations.name', 'addresses.text', 'practitioner_roles.organization_id', 'practitioner_roles.speciality_id', 'cities.name']) ->orderBy('organizations.name'); }) ->leftJoin('addresses', function (Builder $query) { @@ -64,7 +66,6 @@ class SearchController extends Controller ->where('specialities.name', 'LIKE', "{$request->value}%") ->where('addresses.addressable_type', '=', Organization::class) ->whereNot('practitioner_roles.speciality_id') - ->groupBy(['practitioner_roles.organization_id', 'practitioner_roles.speciality_id']) ->get(); return Helper::responseJson(data: ['hospitals' => HospitalResource::collection($queryHospitals)], message: 'Data rumah sakit berhasil di ambil'); diff --git a/Modules/Linksehat/Http/Controllers/Api/SpecialityController.php b/Modules/Linksehat/Http/Controllers/Api/SpecialityController.php index a010664e..1740cd9d 100755 --- a/Modules/Linksehat/Http/Controllers/Api/SpecialityController.php +++ b/Modules/Linksehat/Http/Controllers/Api/SpecialityController.php @@ -39,6 +39,8 @@ class SpecialityController extends Controller ->where('speciality_id', $specialityId) ->get(); + abort_if(count($doctors) === 0, Response::HTTP_NOT_FOUND, 'Data Doctor tidak ditemukan'); + foreach ($doctors as $key => $doctor) { $specialisName = $doctor->speciality->name; } diff --git a/Modules/Linksehat/Routes/api.php b/Modules/Linksehat/Routes/api.php index a75f8329..3e09e274 100755 --- a/Modules/Linksehat/Routes/api.php +++ b/Modules/Linksehat/Routes/api.php @@ -58,6 +58,6 @@ Route::prefix('linksehat')->group(function () { Route::middleware('auth:sanctum')->group(function () { Route::get('profile', [ProfileController::class, 'index'])->name('profile'); Route::post('profile', [ProfileController::class, 'update'])->name('profile.update'); - Route::apiResource('persons', PersonController::class)->except(['destroy']); + Route::apiResource('families', PersonController::class)->except(['destroy']); }); }); diff --git a/database/seeders/OrganizationSeeder.php b/database/seeders/OrganizationSeeder.php index e3b4be3c..9a169be5 100755 --- a/database/seeders/OrganizationSeeder.php +++ b/database/seeders/OrganizationSeeder.php @@ -16,20 +16,20 @@ class OrganizationSeeder extends Seeder */ public function run() { - $response = Http::get('https://api.primaya.id/temp/organizations'); + $response = Http::get('https://app.primaya.id/temp/organizations'); foreach ($response->json()['organizations'] as $organization) { $newOrganization = Organization::updateOrCreate([ - 'code' => 'ORG000'.$organization['code'], - ],[ - 'code' => 'ORG000'.$organization['code'], + 'code' => 'ORG000' . $organization['code'], + ], [ + 'code' => 'ORG000' . $organization['code'], 'name' => $organization['name'], 'type' => 'hospital', ]); $newAddress = $newOrganization->addresses()->updateOrCreate([ 'id' => $newOrganization->main_address_id - ],[ + ], [ 'use' => 'both', 'type' => 'physical', 'text' => $organization['address'], @@ -49,14 +49,15 @@ class OrganizationSeeder extends Seeder ]); $newOrganization->metas()->updateOrCreate([ 'type' => 'phone', - ],[ + ], [ 'system' => 'default', 'type' => 'phone', 'value' => $organization['phone'] ]); $newOrganization->metas()->updateOrCreate([ 'type' => 'timezone', - ],['system' => 'default', + ], [ + 'system' => 'default', 'type' => 'timezone', 'value' => $organization['timezone'] ]);