Browse Source

fix when checkLocation when mobile do presence

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

32
app/Http/Controllers/PresenceController.php

@ -116,23 +116,23 @@ class PresenceController extends Controller
->whereDate("ma.end_date", ">=", $params->clock_time) ->whereDate("ma.end_date", ">=", $params->clock_time)
->get(); ->get();
$temp = []; $temp = [];
foreach($geom as $dataGeom){ if (count($geom) > 0) {
$valGeom = json_decode($dataGeom->geom); foreach($geom as $dataGeom){
if($params->type=="out"){ $valGeom = json_decode($dataGeom->geom);
$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")); if($params->type=="out"){
}else{ $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"));
$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")); }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){ foreach ($check as $key) {
$temp[]=array( if($key->boundary){
"activity_id" => $dataGeom->id, $temp[]=array(
"boundary" => $key->boundary "activity_id" => $dataGeom->id,
); "boundary" => $key->boundary
} );
}
}
} }
} }
return $temp; return $temp;
} }

Loading…
Cancel
Save