@fleetbase/fleetops-engine 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/components/context-panel.hbs +5 -0
- package/addon/components/context-panel.js +6 -0
- package/addon/components/driver-card-mini.js +34 -13
- package/addon/components/driver-form-panel.hbs +23 -23
- package/addon/components/driver-form-panel.js +96 -13
- package/addon/components/driver-panel.hbs +12 -12
- package/addon/components/driver-panel.js +125 -21
- package/addon/components/fleet-vehicle-listing.hbs +1 -1
- package/addon/components/live-map.hbs +20 -9
- package/addon/components/live-map.js +1255 -353
- package/addon/components/map-container/toolbar/visibility-control-panel.hbs +66 -0
- package/addon/components/map-container/toolbar/visibility-control-panel.js +74 -0
- package/addon/components/map-container/toolbar/zones-panel.hbs +10 -10
- package/addon/components/map-container/toolbar/zones-panel.js +90 -61
- package/addon/components/map-container/toolbar.hbs +12 -7
- package/addon/components/modals/vehicle-form.hbs +35 -35
- package/addon/components/settings-window.hbs +1 -1
- package/addon/components/vehicle-form-panel.hbs +25 -26
- package/addon/components/vehicle-form-panel.js +95 -12
- package/addon/components/vehicle-panel.hbs +12 -13
- package/addon/components/vehicle-panel.js +130 -20
- package/addon/controllers/management/drivers/index/details.js +53 -0
- package/addon/controllers/management/drivers/index/edit.js +77 -46
- package/addon/controllers/management/drivers/index/new.js +39 -79
- package/addon/controllers/management/drivers/index.js +17 -221
- package/addon/controllers/management/fleets/index/edit.js +1 -1
- package/addon/controllers/management/fleets/index/new.js +1 -1
- package/addon/controllers/management/fuel-reports/index.js +2 -2
- package/addon/controllers/management/vehicles/index/details.js +49 -0
- package/addon/controllers/management/vehicles/index/edit.js +104 -1
- package/addon/controllers/management/vehicles/index/new.js +71 -0
- package/addon/controllers/operations/orders/index/new.js +4 -6
- package/addon/controllers/operations/orders/index/view.js +22 -14
- package/addon/controllers/operations/orders/index.js +124 -50
- package/addon/controllers/operations/service-rates/index/edit.js +1 -1
- package/addon/controllers/operations/service-rates/index/new.js +1 -1
- package/addon/engine.js +6 -0
- package/addon/helpers/is-visibility-control-visible.js +18 -0
- package/addon/routes/application.js +1 -1
- package/addon/routes/home.js +1 -1
- package/addon/routes/management/drivers/index/details.js +5 -0
- package/addon/routes/operations/orders/index/view.js +4 -2
- package/addon/routes/operations/orders/index.js +5 -1
- package/addon/routes/operations/service-rates/index.js +1 -1
- package/addon/routes/operations/zones/index.js +1 -1
- package/addon/services/context-panel.js +173 -0
- package/addon/services/leaflet-contextmenu-manager.js +311 -0
- package/addon/services/leaflet-map-manager.js +61 -0
- package/addon/services/service-areas.js +242 -32
- package/addon/templates/application.hbs +2 -1
- package/addon/templates/management/drivers/index/details.hbs +1 -1
- package/addon/templates/management/drivers/index/edit.hbs +1 -1
- package/addon/templates/management/drivers/index/new.hbs +1 -1
- package/addon/templates/management/vehicles/index/details.hbs +1 -1
- package/addon/templates/management/vehicles/index/edit.hbs +1 -1
- package/addon/templates/management/vehicles/index/new.hbs +1 -1
- package/addon/templates/operations/orders/index/view.hbs +2 -2
- package/addon/templates/operations/orders/index.hbs +1 -1
- package/addon/utils/apply-context-component-arguments.js +31 -0
- package/addon/utils/context-component-callback.js +16 -0
- package/addon/utils/find-leaflet-layer.js +13 -0
- package/addon/utils/fly-to-leaflet-layer.js +25 -0
- package/addon/utils/get-leaflet-layer-by-id.js +12 -0
- package/addon/utils/layer-can-bind-contextmenu.js +3 -0
- package/app/components/context-panel.js +1 -0
- package/app/components/map-container/toolbar/visibility-control-panel.js +1 -0
- package/app/helpers/is-visibility-control-visible.js +1 -0
- package/app/services/context-panel.js +1 -0
- package/app/services/leaflet-contextmenu-manager.js +1 -0
- package/app/services/leaflet-map-manager.js +1 -0
- package/app/utils/apply-context-component-arguments.js +1 -0
- package/app/utils/context-component-callback.js +1 -0
- package/app/utils/find-leaflet-layer.js +1 -0
- package/app/utils/fly-to-leaflet-layer.js +1 -0
- package/app/utils/get-leaflet-layer-by-id.js +1 -0
- package/app/utils/layer-can-bind-contextmenu.js +1 -0
- package/composer.json +11 -1
- package/extension.json +1 -1
- package/package.json +3 -3
- package/server/migrations/2023_09_14_074512_update_vehicles_table.php +89 -88
- package/server/migrations/2023_10_25_093014_create_vehicle_device_events_table.php +56 -0
- package/server/src/Http/Controllers/Internal/v1/LiveController.php +7 -4
- package/server/src/Http/Filter/VehicleFilter.php +7 -0
- package/server/src/Http/Resources/v1/Vehicle.php +52 -39
- package/server/src/Models/VehicleDevice.php +17 -3
- package/server/src/Models/VehicleDeviceEvent.php +90 -0
- package/addon/services/map-manager.js +0 -3
- package/app/services/map-manager.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/utils/get-leaflet-layer-by-id';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/utils/layer-can-bind-contextmenu';
|
package/composer.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetbase/fleetops-api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Fleet & Transport Management Extension for Fleetbase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fleetbase-extension",
|
|
@@ -60,6 +60,16 @@
|
|
|
60
60
|
"Fleetbase\\FleetOps\\Providers\\FleetOpsServiceProvider",
|
|
61
61
|
"Fleetbase\\FleetOps\\Providers\\EventServiceProvider"
|
|
62
62
|
]
|
|
63
|
+
},
|
|
64
|
+
"fleetbase/fleetops-api": {
|
|
65
|
+
"excludes": [
|
|
66
|
+
"addon",
|
|
67
|
+
"app",
|
|
68
|
+
"assets",
|
|
69
|
+
"config",
|
|
70
|
+
"tests",
|
|
71
|
+
"vendor"
|
|
72
|
+
]
|
|
63
73
|
}
|
|
64
74
|
},
|
|
65
75
|
"config": {
|
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetbase/fleetops-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Fleet & Transport Management Extension for Fleetbase",
|
|
5
5
|
"fleetbase": {
|
|
6
6
|
"route": "fleet-ops",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"publish:github": "npm config set '@fleetbase:registry' https://npm.pkg.github.com/ && npm publish"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@fleetbase/ember-core": "^0.1.
|
|
43
|
-
"@fleetbase/ember-ui": "^0.2.
|
|
42
|
+
"@fleetbase/ember-core": "^0.1.6",
|
|
43
|
+
"@fleetbase/ember-ui": "^0.2.1",
|
|
44
44
|
"@fleetbase/fleetops-data": "^0.1.1",
|
|
45
45
|
"@fleetbase/leaflet-routing-machine": "^3.2.16",
|
|
46
46
|
"@fortawesome/ember-fontawesome": "^0.4.1",
|
|
@@ -6,95 +6,96 @@ use Illuminate\Support\Facades\Schema;
|
|
|
6
6
|
|
|
7
7
|
class UpdateVehiclesTable extends Migration
|
|
8
8
|
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!Schema::hasColumn('vehicles', 'model')) {
|
|
16
|
-
$table->string('model')->nullable()->after('make');
|
|
17
|
-
}
|
|
18
|
-
if (!Schema::hasColumn('vehicles', 'model_data')) {
|
|
19
|
-
$table->json('model_data')->nullable()->after('meta');
|
|
20
|
-
}
|
|
21
|
-
if (!Schema::hasColumn('vehicles', 'telematics')) {
|
|
22
|
-
$table->json('telematics')->nullable()->after('meta');
|
|
23
|
-
}
|
|
9
|
+
public function up()
|
|
10
|
+
{
|
|
11
|
+
Schema::table('vehicles', function (Blueprint $table) {
|
|
12
|
+
if (!Schema::hasColumn('vehicles', 'location')) {
|
|
13
|
+
$table->point('location')->nullable()->after('avatar_url');
|
|
14
|
+
}
|
|
24
15
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'model_engine_cyl',
|
|
35
|
-
'model_engine_fuel',
|
|
36
|
-
'model_engine_position',
|
|
37
|
-
'model_engine_power_ps',
|
|
38
|
-
'model_engine_power_rpm',
|
|
39
|
-
'model_engine_stroke_mm',
|
|
40
|
-
'model_engine_torque_nm',
|
|
41
|
-
'model_engine_torque_rpm',
|
|
42
|
-
'model_engine_valves_per_cyl',
|
|
43
|
-
'model_fuel_cap_l',
|
|
44
|
-
'model_length_mm',
|
|
45
|
-
'model_lkm_city',
|
|
46
|
-
'model_lkm_hwy',
|
|
47
|
-
'model_lkm_mixed',
|
|
48
|
-
'model_make_display',
|
|
49
|
-
'model_seats',
|
|
50
|
-
'model_sold_in_us',
|
|
51
|
-
'model_top_speed_kph',
|
|
52
|
-
'model_transmission_type',
|
|
53
|
-
'model_weight_kg',
|
|
54
|
-
'model_wheelbase_mm',
|
|
55
|
-
'model_width_mm',
|
|
56
|
-
]);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
16
|
+
if (!Schema::hasColumn('vehicles', 'model')) {
|
|
17
|
+
$table->string('model')->nullable()->after('make');
|
|
18
|
+
}
|
|
19
|
+
if (!Schema::hasColumn('vehicles', 'model_data')) {
|
|
20
|
+
$table->json('model_data')->nullable()->after('meta');
|
|
21
|
+
}
|
|
22
|
+
if (!Schema::hasColumn('vehicles', 'telematics')) {
|
|
23
|
+
$table->json('telematics')->nullable()->after('meta');
|
|
24
|
+
}
|
|
59
25
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
26
|
+
$table->dropColumn([
|
|
27
|
+
'model_0_to_100_kph',
|
|
28
|
+
'model_body',
|
|
29
|
+
'model_co2',
|
|
30
|
+
'model_doors',
|
|
31
|
+
'model_drive',
|
|
32
|
+
'model_engine_bore_mm',
|
|
33
|
+
'model_engine_cc',
|
|
34
|
+
'model_engine_compression',
|
|
35
|
+
'model_engine_cyl',
|
|
36
|
+
'model_engine_fuel',
|
|
37
|
+
'model_engine_position',
|
|
38
|
+
'model_engine_power_ps',
|
|
39
|
+
'model_engine_power_rpm',
|
|
40
|
+
'model_engine_stroke_mm',
|
|
41
|
+
'model_engine_torque_nm',
|
|
42
|
+
'model_engine_torque_rpm',
|
|
43
|
+
'model_engine_valves_per_cyl',
|
|
44
|
+
'model_fuel_cap_l',
|
|
45
|
+
'model_length_mm',
|
|
46
|
+
'model_lkm_city',
|
|
47
|
+
'model_lkm_hwy',
|
|
48
|
+
'model_lkm_mixed',
|
|
49
|
+
'model_make_display',
|
|
50
|
+
'model_seats',
|
|
51
|
+
'model_sold_in_us',
|
|
52
|
+
'model_top_speed_kph',
|
|
53
|
+
'model_transmission_type',
|
|
54
|
+
'model_weight_kg',
|
|
55
|
+
'model_wheelbase_mm',
|
|
56
|
+
'model_width_mm',
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
61
|
+
public function down()
|
|
62
|
+
{
|
|
63
|
+
Schema::table('vehicles', function (Blueprint $table) {
|
|
64
|
+
$table->dropColumn('location');
|
|
65
|
+
$table->dropColumn('model');
|
|
66
|
+
$table->dropColumn('model_data');
|
|
67
|
+
$table->dropColumn('telematics');
|
|
68
|
+
|
|
69
|
+
$table->string('model_0_to_100_kph')->nullable();
|
|
70
|
+
$table->string('model_body')->nullable();
|
|
71
|
+
$table->string('model_co2')->nullable();
|
|
72
|
+
$table->string('model_doors')->nullable();
|
|
73
|
+
$table->string('model_drive')->nullable();
|
|
74
|
+
$table->string('model_engine_bore_mm')->nullable();
|
|
75
|
+
$table->string('model_engine_cc')->nullable();
|
|
76
|
+
$table->string('model_engine_compression')->nullable();
|
|
77
|
+
$table->string('model_engine_cyl')->nullable();
|
|
78
|
+
$table->string('model_engine_fuel')->nullable();
|
|
79
|
+
$table->string('model_engine_position')->nullable();
|
|
80
|
+
$table->string('model_engine_power_ps')->nullable();
|
|
81
|
+
$table->string('model_engine_power_rpm')->nullable();
|
|
82
|
+
$table->string('model_engine_stroke_mm')->nullable();
|
|
83
|
+
$table->string('model_engine_torque_nm')->nullable();
|
|
84
|
+
$table->string('model_engine_torque_rpm')->nullable();
|
|
85
|
+
$table->string('model_engine_valves_per_cyl')->nullable();
|
|
86
|
+
$table->string('model_fuel_cap_l')->nullable();
|
|
87
|
+
$table->string('model_length_mm')->nullable();
|
|
88
|
+
$table->string('model_lkm_city')->nullable();
|
|
89
|
+
$table->string('model_lkm_hwy')->nullable();
|
|
90
|
+
$table->string('model_lkm_mixed')->nullable();
|
|
91
|
+
$table->string('model_make_display')->nullable();
|
|
92
|
+
$table->string('model_seats')->nullable();
|
|
93
|
+
$table->string('model_sold_in_us')->nullable();
|
|
94
|
+
$table->string('model_top_speed_kph')->nullable();
|
|
95
|
+
$table->string('model_transmission_type')->nullable();
|
|
96
|
+
$table->string('model_weight_kg')->nullable();
|
|
97
|
+
$table->string('model_wheelbase_mm')->nullable();
|
|
98
|
+
$table->string('model_width_mm')->nullable();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
100
101
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
use Illuminate\Database\Migrations\Migration;
|
|
4
|
+
use Illuminate\Database\Schema\Blueprint;
|
|
5
|
+
use Illuminate\Support\Facades\Schema;
|
|
6
|
+
|
|
7
|
+
class CreateVehicleDeviceEventsTable extends Migration
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Run the migrations.
|
|
11
|
+
*
|
|
12
|
+
* @return void
|
|
13
|
+
*/
|
|
14
|
+
public function up()
|
|
15
|
+
{
|
|
16
|
+
// fix indexes on vehicle_devices table
|
|
17
|
+
Schema::table('vehicle_devices', function (Blueprint $table) {
|
|
18
|
+
$table->index('uuid');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// create events table
|
|
22
|
+
Schema::create('vehicle_device_events', function (Blueprint $table) {
|
|
23
|
+
$table->increments('id');
|
|
24
|
+
$table->uuid('uuid')->nullable();
|
|
25
|
+
$table->uuid('vehicle_device_uuid');
|
|
26
|
+
$table->foreign('vehicle_device_uuid')->references('uuid')->on('vehicle_devices');
|
|
27
|
+
$table->json('payload')->nullable();
|
|
28
|
+
$table->json('meta')->nullable();
|
|
29
|
+
$table->string('ident')->nullable();
|
|
30
|
+
$table->string('protocol')->nullable();
|
|
31
|
+
$table->string('provider')->nullable();
|
|
32
|
+
$table->point('location')->nullable();
|
|
33
|
+
$table->string('mileage')->nullable();
|
|
34
|
+
$table->string('state')->nullable();
|
|
35
|
+
$table->string('code')->nullable();
|
|
36
|
+
$table->string('reason')->nullable();
|
|
37
|
+
$table->softDeletes();
|
|
38
|
+
$table->timestamps();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Reverse the migrations.
|
|
44
|
+
*
|
|
45
|
+
* @return void
|
|
46
|
+
*/
|
|
47
|
+
public function down()
|
|
48
|
+
{
|
|
49
|
+
Schema::dropIfExists('vehicle_device_events');
|
|
50
|
+
|
|
51
|
+
// fix indexes on vehicle_devices table
|
|
52
|
+
Schema::table('vehicle_devices', function (Blueprint $table) {
|
|
53
|
+
$table->dropIndex(['uuid']);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Http\Controllers\Internal\v1;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Http\Filter\PlaceFilter;
|
|
6
|
+
use Fleetbase\FleetOps\Http\Resources\v1\Driver as DriverResource;
|
|
6
7
|
use Fleetbase\FleetOps\Http\Resources\v1\Order as OrderResource;
|
|
8
|
+
use Fleetbase\FleetOps\Http\Resources\v1\Place as PlaceResource;
|
|
9
|
+
use Fleetbase\FleetOps\Http\Resources\v1\Vehicle as VehicleResource;
|
|
7
10
|
use Fleetbase\FleetOps\Models\Driver;
|
|
8
11
|
use Fleetbase\FleetOps\Models\Order;
|
|
9
12
|
use Fleetbase\FleetOps\Models\Place;
|
|
@@ -94,7 +97,7 @@ class LiveController extends Controller
|
|
|
94
97
|
)
|
|
95
98
|
->get();
|
|
96
99
|
|
|
97
|
-
return
|
|
100
|
+
return DriverResource::collection($drivers);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
/**
|
|
@@ -105,9 +108,9 @@ class LiveController extends Controller
|
|
|
105
108
|
public function vehicles()
|
|
106
109
|
{
|
|
107
110
|
// Fetch vehicles that are online
|
|
108
|
-
$vehicles = Vehicle::where(['company_uuid' => session('company')
|
|
111
|
+
$vehicles = Vehicle::where(['company_uuid' => session('company')])->with(['devices'])->get();
|
|
109
112
|
|
|
110
|
-
return
|
|
113
|
+
return VehicleResource::collection($vehicles);
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
/**
|
|
@@ -122,6 +125,6 @@ class LiveController extends Controller
|
|
|
122
125
|
->filter(new PlaceFilter($request))
|
|
123
126
|
->get();
|
|
124
127
|
|
|
125
|
-
return
|
|
128
|
+
return PlaceResource::collection($places);
|
|
126
129
|
}
|
|
127
130
|
}
|
|
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
6
|
use Fleetbase\Support\Http;
|
|
7
|
+
use Grimzy\LaravelMysqlSpatial\Types\Point;
|
|
7
8
|
|
|
8
9
|
class Vehicle extends FleetbaseResource
|
|
9
10
|
{
|
|
@@ -19,27 +20,34 @@ class Vehicle extends FleetbaseResource
|
|
|
19
20
|
return array_merge(
|
|
20
21
|
$this->getInternalIds(),
|
|
21
22
|
[
|
|
22
|
-
'id'
|
|
23
|
-
'uuid'
|
|
24
|
-
'public_id'
|
|
25
|
-
'internal_id'
|
|
26
|
-
'name'
|
|
27
|
-
'display_name'
|
|
28
|
-
'vin'
|
|
29
|
-
'driver'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
23
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
24
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
25
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
26
|
+
'internal_id' => $this->internal_id,
|
|
27
|
+
'name' => $this->display_name,
|
|
28
|
+
'display_name' => $this->when(Http::isInternalRequest(), $this->display_name),
|
|
29
|
+
'vin' => $this->vin ?? null,
|
|
30
|
+
'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
|
|
31
|
+
'devices' => $this->whenLoaded('devices', $this->devices),
|
|
32
|
+
'photo' => $this->photoUrl,
|
|
33
|
+
'avatar_url' => $this->avatar_url,
|
|
34
|
+
'make' => $this->make,
|
|
35
|
+
'model' => $this->model,
|
|
36
|
+
'year' => $this->year,
|
|
37
|
+
'trim' => $this->trim,
|
|
38
|
+
'type' => $this->type,
|
|
39
|
+
'plate_number' => $this->plate_number,
|
|
40
|
+
'vin' => $this->vin,
|
|
41
|
+
'vin_data' => $this->vin_data,
|
|
42
|
+
'status' => $this->status,
|
|
43
|
+
'online' => $this->online,
|
|
44
|
+
'location' => data_get($this, 'location', new Point(0, 0)),
|
|
45
|
+
'heading' => (int) data_get($this, 'heading', 0),
|
|
46
|
+
'altitude' => (int) data_get($this, 'altitude', 0),
|
|
47
|
+
'speed' => (int) data_get($this, 'speed', 0),
|
|
48
|
+
'meta' => $this->meta ?? [],
|
|
49
|
+
'updated_at' => $this->updated_at,
|
|
50
|
+
'created_at' => $this->created_at,
|
|
43
51
|
]
|
|
44
52
|
);
|
|
45
53
|
}
|
|
@@ -52,24 +60,29 @@ class Vehicle extends FleetbaseResource
|
|
|
52
60
|
public function toWebhookPayload()
|
|
53
61
|
{
|
|
54
62
|
return [
|
|
55
|
-
'id'
|
|
56
|
-
'internal_id'
|
|
57
|
-
'name'
|
|
58
|
-
'vin'
|
|
59
|
-
'driver'
|
|
60
|
-
'photo'
|
|
61
|
-
'make'
|
|
62
|
-
'model'
|
|
63
|
-
'year'
|
|
64
|
-
'trim'
|
|
65
|
-
'type'
|
|
66
|
-
'plate_number'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
63
|
+
'id' => $this->public_id,
|
|
64
|
+
'internal_id' => $this->internal_id,
|
|
65
|
+
'name' => $this->name,
|
|
66
|
+
'vin' => $this->vin ?? null,
|
|
67
|
+
'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
|
|
68
|
+
'photo' => $this->photoUrl,
|
|
69
|
+
'make' => $this->make,
|
|
70
|
+
'model' => $this->model,
|
|
71
|
+
'year' => $this->year,
|
|
72
|
+
'trim' => $this->trim,
|
|
73
|
+
'type' => $this->type,
|
|
74
|
+
'plate_number' => $this->plate_number,
|
|
75
|
+
'vin' => $this->vin,
|
|
76
|
+
'vin_data' => $this->vin_data,
|
|
77
|
+
'status' => $this->status,
|
|
78
|
+
'online' => $this->online,
|
|
79
|
+
'location' => data_get($this, 'location', new Point(0, 0)),
|
|
80
|
+
'heading' => (int) data_get($this, 'heading', 0),
|
|
81
|
+
'altitude' => (int) data_get($this, 'altitude', 0),
|
|
82
|
+
'speed' => (int) data_get($this, 'speed', 0),
|
|
83
|
+
'meta' => $this->meta ?? [],
|
|
84
|
+
'updated_at' => $this->updated_at,
|
|
85
|
+
'created_at' => $this->created_at,
|
|
73
86
|
];
|
|
74
87
|
}
|
|
75
88
|
}
|
|
@@ -10,9 +10,7 @@ use Fleetbase\Traits\TracksApiCredential;
|
|
|
10
10
|
|
|
11
11
|
class VehicleDevice extends Model
|
|
12
12
|
{
|
|
13
|
-
use HasUuid;
|
|
14
|
-
use TracksApiCredential;
|
|
15
|
-
use HasApiModelBehavior;
|
|
13
|
+
use HasUuid, TracksApiCredential, HasApiModelBehavior;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* The database table used by the model.
|
|
@@ -76,4 +74,20 @@ class VehicleDevice extends Model
|
|
|
76
74
|
* @var array
|
|
77
75
|
*/
|
|
78
76
|
protected $hidden = [];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
80
|
+
*/
|
|
81
|
+
public function vehicle()
|
|
82
|
+
{
|
|
83
|
+
return $this->belongsTo(Vehicle::class);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
88
|
+
*/
|
|
89
|
+
public function events()
|
|
90
|
+
{
|
|
91
|
+
return $this->hasMany(VehicleDeviceEvent::class);
|
|
92
|
+
}
|
|
79
93
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Models;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Casts\Json;
|
|
6
|
+
use Fleetbase\FleetOps\Casts\Point;
|
|
7
|
+
use Fleetbase\Models\Model;
|
|
8
|
+
use Fleetbase\Traits\HasApiModelBehavior;
|
|
9
|
+
use Fleetbase\Traits\HasUuid;
|
|
10
|
+
use Fleetbase\Traits\Searchable;
|
|
11
|
+
use Fleetbase\Traits\TracksApiCredential;
|
|
12
|
+
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
|
|
13
|
+
|
|
14
|
+
class VehicleDeviceEvent extends Model
|
|
15
|
+
{
|
|
16
|
+
use HasUuid, TracksApiCredential, HasApiModelBehavior, SpatialTrait, Searchable;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The database table used by the model.
|
|
20
|
+
*
|
|
21
|
+
* @var string
|
|
22
|
+
*/
|
|
23
|
+
protected $table = 'vehicle_device_events';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Attributes that is filterable on this model.
|
|
27
|
+
*
|
|
28
|
+
* @var array
|
|
29
|
+
*/
|
|
30
|
+
protected $fillable = [
|
|
31
|
+
'uuid',
|
|
32
|
+
'vehicle_device_uuid',
|
|
33
|
+
'payload',
|
|
34
|
+
'meta',
|
|
35
|
+
'location',
|
|
36
|
+
'ident',
|
|
37
|
+
'protocol',
|
|
38
|
+
'provider',
|
|
39
|
+
'mileage',
|
|
40
|
+
'state',
|
|
41
|
+
'code',
|
|
42
|
+
'reason',
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* The attributes that should be cast to native types.
|
|
46
|
+
*
|
|
47
|
+
* @var array
|
|
48
|
+
*/
|
|
49
|
+
protected $casts = [
|
|
50
|
+
'payload' => Json::class,
|
|
51
|
+
'meta' => Json::class,
|
|
52
|
+
'location' => Point::class,
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The attributes that are spatial columns.
|
|
57
|
+
*
|
|
58
|
+
* @var array
|
|
59
|
+
*/
|
|
60
|
+
protected $spatialFields = ['location'];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Dynamic attributes that are appended to object.
|
|
64
|
+
*
|
|
65
|
+
* @var array
|
|
66
|
+
*/
|
|
67
|
+
protected $appends = [];
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Filterable params.
|
|
71
|
+
*
|
|
72
|
+
* @var array
|
|
73
|
+
*/
|
|
74
|
+
protected $filterParams = [];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The attributes excluded from the model's JSON form.
|
|
78
|
+
*
|
|
79
|
+
* @var array
|
|
80
|
+
*/
|
|
81
|
+
protected $hidden = [];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
85
|
+
*/
|
|
86
|
+
public function device()
|
|
87
|
+
{
|
|
88
|
+
return $this->belongsTo(VehicleDevice::class);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@fleetbase/fleetops-engine/services/map-manager';
|