From d6ca4b1d0e97b04bbf6e8914cd9c7d0e83055a7f Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 9 Feb 2023 14:07:00 +0700 Subject: [PATCH] Display name clock in clock out --- app/Http/Controllers/Controller.php | 5 +++++ app/Http/Controllers/PresenceController.php | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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); }