Browse Source

fix when checkLocation when mobile do presence

pull/3/head
ardhi 2 years ago
parent
commit
6e92aab7c7
  1. 30
      app/Http/Controllers/PresenceController.php

30
app/Http/Controllers/PresenceController.php

@ -116,23 +116,23 @@ class PresenceController extends Controller
->whereDate("ma.end_date", ">=", $params->clock_time)
->get();
$temp = [];
foreach($geom as $dataGeom){
$valGeom = json_decode($dataGeom->geom);
if($params->type=="out"){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326)) as boundary"));
}else{
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary"));
}
foreach ($check as $key) {
if($key->boundary){
$temp[]=array(
"activity_id" => $dataGeom->id,
"boundary" => $key->boundary
);
if (count($geom) > 0) {
foreach($geom as $dataGeom){
$valGeom = json_decode($dataGeom->geom);
if($params->type=="out"){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326)) as boundary"));
}else{
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary"));
}
foreach ($check as $key) {
if($key->boundary){
$temp[]=array(
"activity_id" => $dataGeom->id,
"boundary" => $key->boundary
);
}
}
}
}
return $temp;
}

Loading…
Cancel
Save