Browse Source

Display name clock in clock out

pull/3/head
Wahyu Ramadhan 2 years ago
parent
commit
d6ca4b1d0e
  1. 5
      app/Http/Controllers/Controller.php
  2. 7
      app/Http/Controllers/PresenceController.php

5
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;
}
}

7
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);
}

Loading…
Cancel
Save