Browse Source

update conflict

pull/3/head
ibnu 2 years ago
parent
commit
17287467b9
  1. 47
      app/Http/Controllers/MapMonitoringController.php
  2. 33
      app/Models/MapMonitoring.php
  3. 61
      rest-client.http
  4. 2
      routes/web.php

47
app/Http/Controllers/MapMonitoringController.php

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

33
app/Models/MapMonitoring.php

@ -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->time_from, $payload->time_to])
->orderBy('created_at', 'desc')
->get();
return $users;
}
}

61
rest-client.http

@ -1,12 +1,12 @@
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NTgzNTM3NSwiZXhwIjoxNjc2NDQwMTc1LCJuYmYiOjE2NzU4MzUzNzUsImp0aSI6IlhyVjlkTW55TXpOazlrTUIiLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.41uAX7bnRwftkC_daRiVwwKcFIN7EDV0Ly_zDuq4_MY @token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzYxODQ5ODgsImV4cCI6MTY3Njc4OTc4OCwibmJmIjoxNjc2MTg0OTg4LCJqdGkiOiJSMkk1R3FLdXM3bWhMUWwzIiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.GlxG-DaiY1Slc0dR8sRK6CvU-F7MTjT47989MImubJ0
# @hostname = https://adw-api.ospro.id/api # @hostname = https://adw-api.ospro.id/api
# @hostname = https://ospro-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api
# @hostname = https://api-iu.ospro.id/api # @hostname = https://api-iu.ospro.id/api
# @hostname = https://api-staging-adw.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api
@hostname = http://localhost:8444/api # @hostname = http://localhost:8444/api
# @hostname = http://103.73.125.81:8444/api # @hostname = http://103.73.125.81:8444/api
# @hostname = http://172.20.10.2:8074/adw-backend/api @hostname = http://localhost:8074/adw-backend/api
###### login ###### login
POST {{hostname}}/login POST {{hostname}}/login
@ -15,8 +15,8 @@ POST {{hostname}}/login
content-type: application/json content-type: application/json
{ {
"username": "admin", "username": "demo",
"password": "1nt3gr4s14" "password": "demo123"
} }
###### Tools Req ###### Tools Req
@ -802,11 +802,11 @@ Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
{ {
"clock_in_lat": -6.2622811, "clock_out_lat": -6.16678379060529,
"clock_in_lng": 106.7881746, "clock_out_lng": 106.9175039866567,
"clock_time": "2023-02-06T16:40:17+07:00", "clock_time": "2023-02-10T14:48:17+07:00",
"type": "in", "type": "in",
"user_id": 1 "user_id": 1247
} }
###### ######
@ -922,4 +922,45 @@ content-type: application/json
"datesend": "2023-02-07T10:44:17+07:00" "datesend": "2023-02-07T10:44:17+07:00"
} }
] ]
} }
#####
POST {{hostname}}/map-monitoring/search
Authorization: Bearer {{token}}
content-type: application/json
{
"time_from": "2023-02-10 00:00:00",
"time_to": "2023-02-10 23:59:00",
}
# {
# "columns": [
# {
# "logic_operator": "range",
# "name": "created_at",
# "operator": "AND",
# "value": "2023-02-10 00:00:00",
# "value1": "2023-02-10 23:59:00"
# }
# ],
# "joins": [
# {
# "column_join": "user_id",
# "column_results": [
# "username", "name"
# ],
# "name": "m_users"
# }
# ],
# "orders": {
# "ascending": false,
# "columns": [
# "created_at"
# ]
# },
# "paging": {
# "length": 25,
# "start": 0
# }
# }

2
routes/web.php

@ -432,6 +432,8 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/project-comment/add', 'ProjectCommentController@add'); $router->post('/project-comment/add', 'ProjectCommentController@add');
$router->put('/project-comment/update/{id}', 'ProjectCommentController@update'); $router->put('/project-comment/update/{id}', 'ProjectCommentController@update');
$router->post('/project-comment/search', 'ProjectCommentController@search'); $router->post('/project-comment/search', 'ProjectCommentController@search');
$router->post('/map-monitoring/search', 'MapMonitoringController@search');
}); });
}); });

Loading…
Cancel
Save