ardhi
2 years ago
4 changed files with 134 additions and 11 deletions
@ -0,0 +1,47 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers; |
||||||
|
|
||||||
|
use Log; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use App\Models\Presence; |
||||||
|
use App\Models\Activity; |
||||||
|
use App\Models\MapMonitoring; |
||||||
|
use GuzzleHttp\Client; |
||||||
|
use Illuminate\Support\Facades\Http; |
||||||
|
use Carbon\Carbon; |
||||||
|
use Illuminate\Support\Facades\DB; |
||||||
|
|
||||||
|
class MapMonitoringController extends Controller |
||||||
|
{ |
||||||
|
// default map monitoring shows today's presence lat lon in the map |
||||||
|
|
||||||
|
public function search(Request $request) |
||||||
|
{ |
||||||
|
// $payload = $request->all(); |
||||||
|
// $dataBuilder = $this->setUpPayload($payload, 't_clock_in_out'); |
||||||
|
// $builder = $dataBuilder['builder']; |
||||||
|
// $countBuilder = $dataBuilder['count']; |
||||||
|
// $dataGet = $builder->get(); |
||||||
|
// $totalRecord = $countBuilder->count(); |
||||||
|
// return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
||||||
|
|
||||||
|
$monitoringData = MapMonitoring::getUsers($request->all()); |
||||||
|
var_dump($monitoringData); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public function list() |
||||||
|
{ |
||||||
|
$data = Presence::all(); |
||||||
|
$countData = $data->count(); |
||||||
|
|
||||||
|
if($data){ |
||||||
|
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); |
||||||
|
}else{ |
||||||
|
return response()->json(['status'=>'failed','message'=>'failed get list presence, please try again later!','code'=>400], 400); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Support\Facades\DB; |
||||||
|
|
||||||
|
class MapMonitoring extends Model |
||||||
|
{ |
||||||
|
protected $table = 't_clock_in_out'; |
||||||
|
|
||||||
|
const CREATED_AT = 'created_at'; |
||||||
|
const UPDATED_AT = 'updated_at'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'user_id', 'clock_in', 'clock_out', 'date_presence', |
||||||
|
'clock_in_lat', 'clock_in_lng', 'clock_out_lat', 'clock_out_lng', |
||||||
|
'clock_in_loc', 'clock_out_loc','clock_in_boundary', 'clock_out_boundary', |
||||||
|
'created_at', 'created_by', 'updated_at', 'updated_by' |
||||||
|
]; |
||||||
|
|
||||||
|
|
||||||
|
public static function getUsers($payload) |
||||||
|
{ |
||||||
|
$users = DB::table($this->table) |
||||||
|
->select('id', 'user_id', 'clock_in', 'clock_out', 'clock_in_lat', 'clock_in_lng', 'clock_out_lat', 'clock_out_lng', 'clock_in_loc', 'clock_out_loc', 'clock_in_boundary', 'clock_out_boundary') |
||||||
|
->whereBetween('created_at', [$payload->timeFrom, $payload->timeTo]) |
||||||
|
->orderBy('created_at', 'desc') |
||||||
|
->get(); |
||||||
|
|
||||||
|
return $users; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue