diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 742db50..a1f786f 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -250,4 +250,9 @@ class Controller extends BaseController $totalCost = AssignMaterial::selectRaw("ISNULL(qty_planning,0)*ISNULL(budget,0) as totalCost")->where("proyek_id", $proyek_id)->where("activity_id", $activity_id)->sum("totalCost"); return $totalCost; } + + private function getLoc($lat, $lng){ + $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); + return $response; + } } diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index a2664b4..4c73a5b 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -274,7 +274,12 @@ class PresenceController extends Controller $dataGet = $builder->get(); $finalData = []; - + foreach($dataGet as $data){ + $responseIn = $this.getLoc($clock_in_lat, $clock_in_lng); + $responseOut = $this.getLoc($clock_in_lat, $clock_in_lng); + $data->clock_in_loc = $responseIn->json()["display_name"]; + $data->clock_out_loc = $responseOut->json()["display_name"]; + } $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); }