@fleetbase/fleetops-engine 0.6.54 → 0.6.56
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/admin/map-settings.hbs +1 -1
- package/addon/components/admin/routing-settings.hbs +2 -1
- package/addon/components/cell/attached-vehicle.hbs +10 -0
- package/addon/components/cell/attached-vehicle.js +58 -0
- package/addon/components/cell/device-identity.hbs +24 -0
- package/addon/components/cell/device-identity.js +129 -0
- package/addon/components/cell/driver-identity.hbs +33 -0
- package/addon/components/cell/driver-identity.js +143 -0
- package/addon/components/cell/equipment-identity.hbs +5 -0
- package/addon/components/cell/equipment-identity.js +48 -0
- package/addon/components/cell/part-identity.hbs +5 -0
- package/addon/components/cell/part-identity.js +63 -0
- package/addon/components/cell/telematic-device.hbs +38 -0
- package/addon/components/cell/telematic-device.js +44 -0
- package/addon/components/cell/telematic-provider.hbs +33 -16
- package/addon/components/cell/telematic-provider.js +50 -8
- package/addon/components/cell/vehicle-identity.hbs +33 -0
- package/addon/components/cell/vehicle-identity.js +138 -0
- package/addon/components/device/details.js +1 -1
- package/addon/components/device/form.hbs +2 -2
- package/addon/components/device/form.js +7 -0
- package/addon/components/device/panel-header.hbs +45 -20
- package/addon/components/device/panel-header.js +49 -1
- package/addon/components/device/panel-tabs/events.hbs +30 -0
- package/addon/components/device/panel-tabs/events.js +128 -0
- package/addon/components/device/panel-tabs/sensors.hbs +30 -0
- package/addon/components/device/panel-tabs/sensors.js +93 -0
- package/addon/components/device/panel-tabs/vehicle.hbs +68 -0
- package/addon/components/device/panel-tabs/vehicle.js +90 -0
- package/addon/components/device-event/details.hbs +192 -0
- package/addon/components/device-event/details.js +151 -0
- package/addon/components/driver/schedule.js +1 -1
- package/addon/components/equipment/form.js +8 -1
- package/addon/components/layout/fleet-ops-sidebar.hbs +1 -1
- package/addon/components/layout/fleet-ops-sidebar.js +20 -6
- package/addon/components/map/drawer/device-event-listing.js +2 -0
- package/addon/components/map/drawer/driver-listing.js +2 -0
- package/addon/components/map/drawer/place-listing.js +2 -0
- package/addon/components/map/drawer/position-listing.hbs +11 -6
- package/addon/components/map/drawer/position-listing.js +17 -4
- package/addon/components/map/drawer/vehicle-listing.js +2 -0
- package/addon/components/sensor/panel-header.hbs +47 -15
- package/addon/components/sensor/panel-header.js +59 -1
- package/addon/components/table/cell/dropdown/action-item.hbs +31 -0
- package/addon/components/table/cell/dropdown/action-item.js +62 -0
- package/addon/components/table/cell/dropdown.hbs +28 -0
- package/addon/components/table/cell/dropdown.js +91 -0
- package/addon/components/telematic/details.hbs +1 -1
- package/addon/components/telematic/form.hbs +2 -2
- package/addon/components/telematic/settings.hbs +1 -1
- package/addon/components/vendor/panel-header.hbs +82 -0
- package/addon/components/vendor/panel-header.js +48 -0
- package/addon/controllers/connectivity/devices/index/details/events.js +1 -1
- package/addon/controllers/connectivity/devices/index/details/vehicle.js +50 -2
- package/addon/controllers/connectivity/devices/index.js +144 -129
- package/addon/controllers/connectivity/events/details.js +70 -0
- package/addon/controllers/connectivity/events/index.js +187 -11
- package/addon/controllers/connectivity/sensors/index.js +160 -14
- package/addon/controllers/connectivity/telematics/details/devices.js +126 -134
- package/addon/controllers/connectivity/telematics/details/events.js +1 -1
- package/addon/controllers/connectivity/telematics/details/sensors.js +4 -0
- package/addon/controllers/maintenance/equipment/index.js +1 -2
- package/addon/controllers/maintenance/parts/index.js +1 -2
- package/addon/controllers/management/drivers/index.js +82 -42
- package/addon/controllers/management/fuel-reports/index.js +63 -4
- package/addon/controllers/management/issues/index.js +63 -4
- package/addon/controllers/management/vehicles/index.js +33 -6
- package/addon/controllers/settings/map.js +15 -0
- package/addon/instance-initializers/register-vroom-allocation.js +1 -1
- package/addon/routes/connectivity/devices/index/details/vehicle.js +24 -2
- package/addon/routes/connectivity/devices/index.js +7 -0
- package/addon/routes/connectivity/events/details.js +28 -0
- package/addon/routes/connectivity/events/index.js +6 -2
- package/addon/routes/connectivity/sensors/index.js +7 -2
- package/addon/routes/connectivity/telematics/details/devices.js +2 -0
- package/addon/routes/management/vehicles/index/details.js +3 -1
- package/addon/services/device-actions.js +30 -0
- package/addon/services/device-event-actions.js +1 -1
- package/addon/services/equipment-actions.js +1 -0
- package/addon/services/map-adapter/google.js +25 -0
- package/addon/services/map-adapter/leaflet.js +1 -1
- package/addon/services/map-adapter-interface.js +1 -1
- package/addon/services/map-manager.js +4 -1
- package/addon/services/map-settings.js +15 -0
- package/addon/services/sensor-actions.js +3 -0
- package/addon/services/service-rate-actions.js +39 -1
- package/addon/services/vehicle-actions.js +24 -12
- package/addon/services/vendor-actions.js +3 -0
- package/addon/styles/fleetops-engine.css +9 -1
- package/addon/templates/connectivity/devices/index/details/vehicle.hbs +66 -2
- package/addon/templates/connectivity/events/details.hbs +40 -0
- package/addon/templates/management/vendors/index/details.hbs +2 -2
- package/addon/templates/settings/map.hbs +38 -9
- package/addon/templates/settings/notifications.hbs +2 -1
- package/addon/templates/settings/routing.hbs +1 -0
- package/addon/utils/device-table-columns.js +288 -0
- package/addon/utils/identity-cell-resource.js +20 -0
- package/addon/utils/leaflet-plugin-loader.js +5 -5
- package/addon/utils/map-drawer-dropdown-position.js +47 -0
- package/addon/utils/route-colors.js +1 -1
- package/addon/utils/trackable-option.js +93 -0
- package/app/components/cell/attached-vehicle.js +1 -0
- package/app/components/cell/device-identity.js +1 -0
- package/app/components/cell/driver-identity.js +1 -0
- package/app/components/cell/equipment-identity.js +1 -0
- package/app/components/cell/part-identity.js +1 -0
- package/app/components/cell/telematic-device.js +1 -0
- package/app/components/cell/vehicle-identity.js +1 -0
- package/app/components/device/panel-tabs/events.hbs +30 -0
- package/app/components/device/panel-tabs/events.js +128 -0
- package/app/components/device/panel-tabs/sensors.hbs +30 -0
- package/app/components/device/panel-tabs/sensors.js +93 -0
- package/app/components/device/panel-tabs/vehicle.hbs +68 -0
- package/app/components/device/panel-tabs/vehicle.js +90 -0
- package/app/components/device-event/details.hbs +192 -0
- package/app/components/device-event/details.js +1 -0
- package/app/components/table/cell/dropdown/action-item.js +1 -0
- package/app/components/table/cell/dropdown.js +1 -0
- package/app/components/vendor/panel-header.js +1 -0
- package/app/controllers/connectivity/events/{index/details.js → details.js} +1 -1
- package/app/routes/connectivity/events/{index/details.js → details.js} +1 -1
- package/app/templates/connectivity/events/{index/details.js → details.js} +1 -1
- package/app/utils/map-drawer-dropdown-position.js +1 -0
- package/app/utils/trackable-option.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +4 -4
- package/server/migrations/2026_06_23_000001_delete_bad_afaqy_telematics_sensors.php +34 -0
- package/server/src/Console/Commands/SyncTelematics.php +4 -4
- package/server/src/Exports/ContactExport.php +12 -5
- package/server/src/Exports/DeviceExport.php +92 -0
- package/server/src/Exports/DriverExport.php +28 -3
- package/server/src/Exports/EquipmentExport.php +94 -0
- package/server/src/Exports/FleetExport.php +22 -7
- package/server/src/Exports/FuelReportExport.php +16 -1
- package/server/src/Exports/IssueExport.php +25 -3
- package/server/src/Exports/MaintenanceExport.php +106 -0
- package/server/src/Exports/MaintenanceScheduleExport.php +99 -0
- package/server/src/Exports/OrderExport.php +24 -5
- package/server/src/Exports/PartExport.php +99 -0
- package/server/src/Exports/PlaceExport.php +33 -7
- package/server/src/Exports/SensorExport.php +94 -0
- package/server/src/Exports/ServiceAreaExport.php +31 -7
- package/server/src/Exports/ServiceRateExport.php +41 -1
- package/server/src/Exports/TelematicExport.php +90 -0
- package/server/src/Exports/VehicleExport.php +274 -8
- package/server/src/Exports/VendorExport.php +15 -2
- package/server/src/Exports/WorkOrderExport.php +92 -0
- package/server/src/Http/Controllers/Api/v1/Concerns/ResolvesFleetOpsApiResources.php +176 -0
- package/server/src/Http/Controllers/Api/v1/DeviceController.php +225 -0
- package/server/src/Http/Controllers/Api/v1/EquipmentController.php +114 -0
- package/server/src/Http/Controllers/Api/v1/FuelTransactionController.php +185 -0
- package/server/src/Http/Controllers/Api/v1/PartController.php +120 -0
- package/server/src/Http/Controllers/Api/v1/SensorController.php +132 -0
- package/server/src/Http/Controllers/Api/v1/WorkOrderController.php +161 -0
- package/server/src/Http/Controllers/Internal/v1/DeviceController.php +36 -1
- package/server/src/Http/Controllers/Internal/v1/DeviceEventController.php +1 -1
- package/server/src/Http/Controllers/Internal/v1/EquipmentController.php +17 -0
- package/server/src/Http/Controllers/Internal/v1/LiveController.php +1 -1
- package/server/src/Http/Controllers/Internal/v1/MaintenanceController.php +17 -0
- package/server/src/Http/Controllers/Internal/v1/MaintenanceScheduleController.php +17 -0
- package/server/src/Http/Controllers/Internal/v1/PartController.php +17 -0
- package/server/src/Http/Controllers/Internal/v1/SensorController.php +18 -0
- package/server/src/Http/Controllers/Internal/v1/ServiceRateController.php +82 -13
- package/server/src/Http/Controllers/Internal/v1/SettingController.php +29 -5
- package/server/src/Http/Controllers/Internal/v1/TelematicController.php +18 -0
- package/server/src/Http/Controllers/Internal/v1/WorkOrderController.php +17 -0
- package/server/src/Http/Filter/DeviceEventFilter.php +21 -0
- package/server/src/Http/Filter/DeviceFilter.php +50 -4
- package/server/src/Http/Filter/EquipmentFilter.php +23 -0
- package/server/src/Http/Filter/FuelProviderTransactionFilter.php +57 -2
- package/server/src/Http/Filter/PartFilter.php +47 -0
- package/server/src/Http/Filter/SensorFilter.php +34 -6
- package/server/src/Http/Filter/WorkOrderFilter.php +23 -0
- package/server/src/Http/Requests/CreateDeviceRequest.php +51 -0
- package/server/src/Http/Requests/CreateEquipmentRequest.php +35 -0
- package/server/src/Http/Requests/CreateFuelTransactionRequest.php +50 -0
- package/server/src/Http/Requests/CreatePartRequest.php +40 -0
- package/server/src/Http/Requests/CreateSensorRequest.php +47 -0
- package/server/src/Http/Requests/CreateWorkOrderRequest.php +42 -0
- package/server/src/Http/Requests/UpdateDeviceRequest.php +7 -0
- package/server/src/Http/Requests/UpdateEquipmentRequest.php +7 -0
- package/server/src/Http/Requests/UpdateFuelTransactionRequest.php +7 -0
- package/server/src/Http/Requests/UpdatePartRequest.php +7 -0
- package/server/src/Http/Requests/UpdateSensorRequest.php +7 -0
- package/server/src/Http/Requests/UpdateWorkOrderRequest.php +7 -0
- package/server/src/Http/Resources/v1/Device.php +72 -0
- package/server/src/Http/Resources/v1/Equipment.php +57 -0
- package/server/src/Http/Resources/v1/FuelTransaction.php +69 -0
- package/server/src/Http/Resources/v1/Index/Vehicle.php +19 -0
- package/server/src/Http/Resources/v1/Part.php +64 -0
- package/server/src/Http/Resources/v1/Sensor.php +68 -0
- package/server/src/Jobs/SyncTelematicDevicesJob.php +194 -38
- package/server/src/Models/Device.php +2 -0
- package/server/src/Models/DeviceEvent.php +81 -0
- package/server/src/Models/Equipment.php +55 -0
- package/server/src/Models/Order.php +2 -1
- package/server/src/Observers/PurchaseRateObserver.php +2 -1
- package/server/src/Support/Analytics/RevenueTrend.php +3 -8
- package/server/src/Support/Metrics/ActiveRevenueQuery.php +121 -0
- package/server/src/Support/Metrics/AvgOrderValueMetric.php +1 -7
- package/server/src/Support/Metrics/EarningsMetric.php +1 -10
- package/server/src/Support/Telematics/Providers/AfaqyProvider.php +105 -5
- package/server/src/Support/Telematics/Providers/FlespiProvider.php +89 -15
- package/server/src/Support/Telematics/Providers/GeotabProvider.php +123 -35
- package/server/src/Support/Telematics/Providers/SafeeProvider.php +567 -47
- package/server/src/Support/Telematics/Providers/SamsaraProvider.php +122 -14
- package/server/src/Support/Telematics/TelematicService.php +28 -9
- package/server/src/routes.php +67 -15
- package/server/tests/DeviceFilterTest.php +9 -0
- package/server/tests/DriverVehicleStatusDefaultTest.php +19 -2
- package/server/tests/EquipmentAssignmentMorphTypeTest.php +35 -0
- package/server/tests/ExportCoverageTest.php +79 -0
- package/server/tests/MetricsRegistryTest.php +45 -5
- package/server/tests/PublicFleetOpsRestEndpointsTest.php +191 -0
- package/server/tests/ServiceRateRouteValidationTest.php +101 -0
- package/server/tests/TelematicsHardeningTest.php +873 -7
- package/addon/controllers/connectivity/events/index/details.js +0 -3
- package/addon/routes/connectivity/events/index/details.js +0 -3
- package/addon/templates/connectivity/events/index/details.hbs +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Filter;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\Vendor;
|
|
6
|
+
use Fleetbase\Http\Filter\Filter;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
|
|
9
|
+
class PartFilter extends Filter
|
|
10
|
+
{
|
|
11
|
+
public function queryForInternal()
|
|
12
|
+
{
|
|
13
|
+
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public function queryForPublic()
|
|
17
|
+
{
|
|
18
|
+
$this->queryForInternal();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public function query(?string $searchQuery)
|
|
22
|
+
{
|
|
23
|
+
$this->builder->search($searchQuery);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public function vendor(?string $vendor)
|
|
27
|
+
{
|
|
28
|
+
if (!$vendor) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
$this->builder->whereIn('vendor_uuid', Vendor::query()
|
|
33
|
+
->where('company_uuid', $this->session->get('company'))
|
|
34
|
+
->where(function ($query) use ($vendor) {
|
|
35
|
+
$query->where('public_id', $vendor);
|
|
36
|
+
|
|
37
|
+
if (in_array('internal_id', (new Vendor())->getFillable())) {
|
|
38
|
+
$query->orWhere('internal_id', $vendor);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (Http::isInternalRequest($this->request)) {
|
|
42
|
+
$query->orWhere('uuid', $vendor);
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
->pluck('uuid'));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Http\Filter;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\FleetOps\Models\Device;
|
|
6
|
+
use Fleetbase\FleetOps\Models\Telematic;
|
|
5
7
|
use Fleetbase\FleetOps\Support\Utils;
|
|
6
8
|
use Fleetbase\Http\Filter\Filter;
|
|
9
|
+
use Fleetbase\Support\Http;
|
|
7
10
|
|
|
8
11
|
class SensorFilter extends Filter
|
|
9
12
|
{
|
|
@@ -47,9 +50,7 @@ class SensorFilter extends Filter
|
|
|
47
50
|
|
|
48
51
|
public function device(?string $device)
|
|
49
52
|
{
|
|
50
|
-
|
|
51
|
-
$this->builder->where('device_uuid', $device);
|
|
52
|
-
}
|
|
53
|
+
$this->wherePublicRelation('device_uuid', Device::class, $device);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
public function deviceUuid(?string $device)
|
|
@@ -59,9 +60,7 @@ class SensorFilter extends Filter
|
|
|
59
60
|
|
|
60
61
|
public function telematic(?string $telematic)
|
|
61
62
|
{
|
|
62
|
-
|
|
63
|
-
$this->builder->where('telematic_uuid', $telematic);
|
|
64
|
-
}
|
|
63
|
+
$this->wherePublicRelation('telematic_uuid', Telematic::class, $telematic);
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
public function telematicUuid(?string $telematic)
|
|
@@ -122,4 +121,33 @@ class SensorFilter extends Filter
|
|
|
122
121
|
$this->builder->whereDate($column, $dates);
|
|
123
122
|
}
|
|
124
123
|
}
|
|
124
|
+
|
|
125
|
+
protected function wherePublicRelation(string $column, string $modelClass, ?string $identifier): void
|
|
126
|
+
{
|
|
127
|
+
if (!$identifier) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
$this->builder->whereIn($column, $this->resolvePublicRelationUuids($modelClass, $identifier, Http::isInternalRequest($this->request)));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
protected function resolvePublicRelationUuids(string $modelClass, string $identifier, bool $allowUuid = false)
|
|
135
|
+
{
|
|
136
|
+
$instance = new $modelClass();
|
|
137
|
+
|
|
138
|
+
return $modelClass::query()
|
|
139
|
+
->where('company_uuid', $this->session->get('company'))
|
|
140
|
+
->where(function ($query) use ($identifier, $instance, $allowUuid) {
|
|
141
|
+
$query->where('public_id', $identifier);
|
|
142
|
+
|
|
143
|
+
if (in_array('internal_id', $instance->getFillable())) {
|
|
144
|
+
$query->orWhere('internal_id', $identifier);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if ($allowUuid) {
|
|
148
|
+
$query->orWhere('uuid', $identifier);
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
->pluck('uuid');
|
|
152
|
+
}
|
|
125
153
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Filter;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Filter\Filter;
|
|
6
|
+
|
|
7
|
+
class WorkOrderFilter extends Filter
|
|
8
|
+
{
|
|
9
|
+
public function queryForInternal()
|
|
10
|
+
{
|
|
11
|
+
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public function queryForPublic()
|
|
15
|
+
{
|
|
16
|
+
$this->queryForInternal();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public function query(?string $searchQuery)
|
|
20
|
+
{
|
|
21
|
+
$this->builder->search($searchQuery);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Rules\ResolvablePoint;
|
|
6
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
7
|
+
use Illuminate\Validation\Rule;
|
|
8
|
+
|
|
9
|
+
class CreateDeviceRequest extends FleetbaseRequest
|
|
10
|
+
{
|
|
11
|
+
public function authorize()
|
|
12
|
+
{
|
|
13
|
+
return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public function rules()
|
|
17
|
+
{
|
|
18
|
+
return [
|
|
19
|
+
'name' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
|
|
20
|
+
'type' => ['nullable', 'string'],
|
|
21
|
+
'device_id' => ['nullable', 'string'],
|
|
22
|
+
'internal_id' => ['nullable', 'string'],
|
|
23
|
+
'imei' => ['nullable', 'string'],
|
|
24
|
+
'imsi' => ['nullable', 'string'],
|
|
25
|
+
'firmware_version' => ['nullable', 'string'],
|
|
26
|
+
'provider' => ['nullable', 'string'],
|
|
27
|
+
'model' => ['nullable', 'string'],
|
|
28
|
+
'manufacturer' => ['nullable', 'string'],
|
|
29
|
+
'serial_number' => ['nullable', 'string'],
|
|
30
|
+
'location' => ['nullable'],
|
|
31
|
+
'last_position' => ['nullable', new ResolvablePoint()],
|
|
32
|
+
'latitude' => ['nullable', 'required_with:longitude'],
|
|
33
|
+
'longitude' => ['nullable', 'required_with:latitude'],
|
|
34
|
+
'installation_date' => ['nullable', 'date'],
|
|
35
|
+
'last_maintenance_date' => ['nullable', 'date'],
|
|
36
|
+
'last_online_at' => ['nullable', 'date'],
|
|
37
|
+
'online' => ['nullable', 'boolean'],
|
|
38
|
+
'status' => ['nullable', 'string'],
|
|
39
|
+
'data_frequency' => ['nullable', 'integer'],
|
|
40
|
+
'notes' => ['nullable', 'string'],
|
|
41
|
+
'telematic' => ['nullable', 'string'],
|
|
42
|
+
'warranty' => ['nullable', 'string'],
|
|
43
|
+
'photo' => ['nullable', 'string'],
|
|
44
|
+
'attachable_type' => ['nullable', 'string'],
|
|
45
|
+
'attachable' => ['nullable', 'required_with:attachable_type', 'string'],
|
|
46
|
+
'meta' => ['nullable', 'array'],
|
|
47
|
+
'data' => ['nullable', 'array'],
|
|
48
|
+
'options' => ['nullable', 'array'],
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
+
use Illuminate\Validation\Rule;
|
|
7
|
+
|
|
8
|
+
class CreateEquipmentRequest extends FleetbaseRequest
|
|
9
|
+
{
|
|
10
|
+
public function authorize()
|
|
11
|
+
{
|
|
12
|
+
return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public function rules()
|
|
16
|
+
{
|
|
17
|
+
return [
|
|
18
|
+
'name' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
|
|
19
|
+
'code' => ['nullable', 'string'],
|
|
20
|
+
'type' => ['nullable', 'string'],
|
|
21
|
+
'status' => ['nullable', 'string'],
|
|
22
|
+
'serial_number' => ['nullable', 'string'],
|
|
23
|
+
'manufacturer' => ['nullable', 'string'],
|
|
24
|
+
'model' => ['nullable', 'string'],
|
|
25
|
+
'warranty' => ['nullable', 'string'],
|
|
26
|
+
'photo' => ['nullable', 'string'],
|
|
27
|
+
'equipable_type' => ['nullable', 'string'],
|
|
28
|
+
'equipable' => ['nullable', 'required_with:equipable_type', 'string'],
|
|
29
|
+
'purchased_at' => ['nullable', 'date'],
|
|
30
|
+
'purchase_price' => ['nullable'],
|
|
31
|
+
'currency' => ['nullable', 'string', 'size:3'],
|
|
32
|
+
'meta' => ['nullable', 'array'],
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
+
use Illuminate\Validation\Rule;
|
|
7
|
+
|
|
8
|
+
class CreateFuelTransactionRequest extends FleetbaseRequest
|
|
9
|
+
{
|
|
10
|
+
public function authorize()
|
|
11
|
+
{
|
|
12
|
+
return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public function rules()
|
|
16
|
+
{
|
|
17
|
+
return [
|
|
18
|
+
'provider' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
|
|
19
|
+
'provider_transaction_id' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
|
|
20
|
+
'connection' => ['nullable', 'string'],
|
|
21
|
+
'fuel_report' => ['nullable', 'string'],
|
|
22
|
+
'vehicle' => ['nullable', 'string'],
|
|
23
|
+
'driver' => ['nullable', 'string'],
|
|
24
|
+
'order' => ['nullable', 'string'],
|
|
25
|
+
'provider_vehicle_id' => ['nullable', 'string'],
|
|
26
|
+
'vehicle_card_id' => ['nullable', 'string'],
|
|
27
|
+
'internal_number' => ['nullable', 'string'],
|
|
28
|
+
'structure_number' => ['nullable', 'string'],
|
|
29
|
+
'plate_number' => ['nullable', 'string'],
|
|
30
|
+
'vin' => ['nullable', 'string'],
|
|
31
|
+
'serial_number' => ['nullable', 'string'],
|
|
32
|
+
'call_sign' => ['nullable', 'string'],
|
|
33
|
+
'trip_number' => ['nullable', 'string'],
|
|
34
|
+
'station_name' => ['nullable', 'string'],
|
|
35
|
+
'station_latitude' => ['nullable', 'numeric'],
|
|
36
|
+
'station_longitude' => ['nullable', 'numeric'],
|
|
37
|
+
'transaction_at' => ['nullable', 'date'],
|
|
38
|
+
'volume' => ['nullable', 'numeric'],
|
|
39
|
+
'metric_unit' => ['nullable', 'string'],
|
|
40
|
+
'amount' => ['nullable'],
|
|
41
|
+
'currency' => ['nullable', 'string', 'size:3'],
|
|
42
|
+
'odometer' => ['nullable', 'numeric'],
|
|
43
|
+
'sync_status' => ['nullable', 'string'],
|
|
44
|
+
'matched_at' => ['nullable', 'date'],
|
|
45
|
+
'normalized_payload' => ['nullable', 'array'],
|
|
46
|
+
'raw_payload' => ['nullable', 'array'],
|
|
47
|
+
'meta' => ['nullable', 'array'],
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
+
use Illuminate\Validation\Rule;
|
|
7
|
+
|
|
8
|
+
class CreatePartRequest extends FleetbaseRequest
|
|
9
|
+
{
|
|
10
|
+
public function authorize()
|
|
11
|
+
{
|
|
12
|
+
return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public function rules()
|
|
16
|
+
{
|
|
17
|
+
return [
|
|
18
|
+
'sku' => ['nullable', 'string'],
|
|
19
|
+
'name' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
|
|
20
|
+
'manufacturer' => ['nullable', 'string'],
|
|
21
|
+
'model' => ['nullable', 'string'],
|
|
22
|
+
'serial_number' => ['nullable', 'string'],
|
|
23
|
+
'barcode' => ['nullable', 'string'],
|
|
24
|
+
'description' => ['nullable', 'string'],
|
|
25
|
+
'quantity_on_hand' => ['nullable', 'integer', 'min:0'],
|
|
26
|
+
'unit_cost' => ['nullable'],
|
|
27
|
+
'msrp' => ['nullable'],
|
|
28
|
+
'currency' => ['nullable', 'string', 'size:3'],
|
|
29
|
+
'asset_type' => ['nullable', 'string'],
|
|
30
|
+
'asset' => ['nullable', 'required_with:asset_type', 'string'],
|
|
31
|
+
'type' => ['nullable', 'string'],
|
|
32
|
+
'status' => ['nullable', 'string'],
|
|
33
|
+
'vendor' => ['nullable', 'string'],
|
|
34
|
+
'warranty' => ['nullable', 'string'],
|
|
35
|
+
'photo' => ['nullable', 'string'],
|
|
36
|
+
'specs' => ['nullable', 'array'],
|
|
37
|
+
'meta' => ['nullable', 'array'],
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Rules\ResolvablePoint;
|
|
6
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
7
|
+
use Illuminate\Validation\Rule;
|
|
8
|
+
|
|
9
|
+
class CreateSensorRequest extends FleetbaseRequest
|
|
10
|
+
{
|
|
11
|
+
public function authorize()
|
|
12
|
+
{
|
|
13
|
+
return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public function rules()
|
|
17
|
+
{
|
|
18
|
+
return [
|
|
19
|
+
'name' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
|
|
20
|
+
'type' => ['nullable', 'string'],
|
|
21
|
+
'internal_id' => ['nullable', 'string'],
|
|
22
|
+
'imei' => ['nullable', 'string'],
|
|
23
|
+
'imsi' => ['nullable', 'string'],
|
|
24
|
+
'firmware_version' => ['nullable', 'string'],
|
|
25
|
+
'serial_number' => ['nullable', 'string'],
|
|
26
|
+
'last_position' => ['nullable', new ResolvablePoint()],
|
|
27
|
+
'latitude' => ['nullable', 'required_with:longitude'],
|
|
28
|
+
'longitude' => ['nullable', 'required_with:latitude'],
|
|
29
|
+
'unit' => ['nullable', 'string'],
|
|
30
|
+
'min_threshold' => ['nullable', 'numeric'],
|
|
31
|
+
'max_threshold' => ['nullable', 'numeric'],
|
|
32
|
+
'threshold_inclusive' => ['nullable', 'boolean'],
|
|
33
|
+
'last_reading_at' => ['nullable', 'date'],
|
|
34
|
+
'last_value' => ['nullable'],
|
|
35
|
+
'calibration' => ['nullable', 'array'],
|
|
36
|
+
'report_frequency_sec' => ['nullable', 'integer'],
|
|
37
|
+
'status' => ['nullable', 'string'],
|
|
38
|
+
'device' => ['nullable', 'string'],
|
|
39
|
+
'telematic' => ['nullable', 'string'],
|
|
40
|
+
'warranty' => ['nullable', 'string'],
|
|
41
|
+
'photo' => ['nullable', 'string'],
|
|
42
|
+
'sensorable_type' => ['nullable', 'string'],
|
|
43
|
+
'sensorable' => ['nullable', 'required_with:sensorable_type', 'string'],
|
|
44
|
+
'meta' => ['nullable', 'array'],
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Requests;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
+
use Illuminate\Validation\Rule;
|
|
7
|
+
|
|
8
|
+
class CreateWorkOrderRequest extends FleetbaseRequest
|
|
9
|
+
{
|
|
10
|
+
public function authorize()
|
|
11
|
+
{
|
|
12
|
+
return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public function rules()
|
|
16
|
+
{
|
|
17
|
+
return [
|
|
18
|
+
'code' => ['nullable', 'string'],
|
|
19
|
+
'subject' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
|
|
20
|
+
'category' => ['nullable', 'string'],
|
|
21
|
+
'status' => ['nullable', 'string'],
|
|
22
|
+
'priority' => ['nullable', 'string'],
|
|
23
|
+
'target_type' => ['nullable', 'string'],
|
|
24
|
+
'target' => ['nullable', 'required_with:target_type', 'string'],
|
|
25
|
+
'assignee_type' => ['nullable', 'string'],
|
|
26
|
+
'assignee' => ['nullable', 'required_with:assignee_type', 'string'],
|
|
27
|
+
'opened_at' => ['nullable', 'date'],
|
|
28
|
+
'due_at' => ['nullable', 'date'],
|
|
29
|
+
'closed_at' => ['nullable', 'date'],
|
|
30
|
+
'instructions' => ['nullable', 'string'],
|
|
31
|
+
'checklist' => ['nullable', 'array'],
|
|
32
|
+
'estimated_cost' => ['nullable'],
|
|
33
|
+
'approved_budget' => ['nullable'],
|
|
34
|
+
'actual_cost' => ['nullable'],
|
|
35
|
+
'currency' => ['nullable', 'string', 'size:3'],
|
|
36
|
+
'cost_breakdown' => ['nullable', 'array'],
|
|
37
|
+
'cost_center' => ['nullable', 'string'],
|
|
38
|
+
'budget_code' => ['nullable', 'string'],
|
|
39
|
+
'meta' => ['nullable', 'array'],
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
use Fleetbase\Support\Resolve;
|
|
9
|
+
|
|
10
|
+
class Device extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
public function toArray($request)
|
|
13
|
+
{
|
|
14
|
+
return $this->withCustomFields([
|
|
15
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
16
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
17
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
18
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
19
|
+
'telematic_uuid' => $this->when(Http::isInternalRequest(), $this->telematic_uuid),
|
|
20
|
+
'attachable_uuid' => $this->when(Http::isInternalRequest(), $this->attachable_uuid),
|
|
21
|
+
'attachable_type' => $this->when(Http::isInternalRequest(), $this->attachable_type ? Utils::toEmberResourceType($this->attachable_type) : null),
|
|
22
|
+
'warranty_uuid' => $this->when(Http::isInternalRequest(), $this->warranty_uuid),
|
|
23
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
24
|
+
'telematic' => $this->whenLoaded('telematic', fn () => $this->resolveLoadedRelation($this->telematic)),
|
|
25
|
+
'attachable' => $this->whenLoaded('attachable', fn () => $this->resolveLoadedRelation($this->attachable)),
|
|
26
|
+
'warranty' => $this->whenLoaded('warranty', fn () => $this->resolveLoadedRelation($this->warranty)),
|
|
27
|
+
'photo' => $this->whenLoaded('photo', fn () => $this->resolveLoadedRelation($this->photo)),
|
|
28
|
+
'type' => $this->type,
|
|
29
|
+
'device_id' => $this->device_id,
|
|
30
|
+
'internal_id' => $this->internal_id,
|
|
31
|
+
'imei' => $this->imei,
|
|
32
|
+
'imsi' => $this->imsi,
|
|
33
|
+
'firmware_version' => $this->firmware_version,
|
|
34
|
+
'provider' => $this->provider,
|
|
35
|
+
'name' => $this->name,
|
|
36
|
+
'model' => $this->model,
|
|
37
|
+
'location' => $this->location,
|
|
38
|
+
'manufacturer' => $this->manufacturer,
|
|
39
|
+
'serial_number' => $this->serial_number,
|
|
40
|
+
'last_position' => $this->last_position,
|
|
41
|
+
'installation_date' => $this->installation_date,
|
|
42
|
+
'last_maintenance_date' => $this->last_maintenance_date,
|
|
43
|
+
'meta' => data_get($this, 'meta', Utils::createObject()),
|
|
44
|
+
'data' => data_get($this, 'data', Utils::createObject()),
|
|
45
|
+
'options' => data_get($this, 'options', Utils::createObject()),
|
|
46
|
+
'online' => $this->online,
|
|
47
|
+
'status' => $this->status,
|
|
48
|
+
'data_frequency' => $this->data_frequency,
|
|
49
|
+
'notes' => $this->notes,
|
|
50
|
+
'last_online_at' => $this->last_online_at,
|
|
51
|
+
'warranty_name' => $this->warranty_name,
|
|
52
|
+
'telematic_name' => $this->telematic_name,
|
|
53
|
+
'is_online' => $this->is_online,
|
|
54
|
+
'attached_to_name' => $this->attached_to_name,
|
|
55
|
+
'connection_status' => $this->connection_status,
|
|
56
|
+
'photo_url' => $this->photo_url,
|
|
57
|
+
'sensors_count' => $this->when(isset($this->sensors_count), $this->sensors_count),
|
|
58
|
+
'slug' => $this->slug,
|
|
59
|
+
'updated_at' => $this->updated_at,
|
|
60
|
+
'created_at' => $this->created_at,
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected function resolveLoadedRelation($model)
|
|
65
|
+
{
|
|
66
|
+
if (!$model) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return Http::isInternalRequest() ? Resolve::httpResourceForModel($model) : $model->public_id;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
use Fleetbase\Support\Resolve;
|
|
9
|
+
|
|
10
|
+
class Equipment extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
public function toArray($request)
|
|
13
|
+
{
|
|
14
|
+
return $this->withCustomFields([
|
|
15
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
16
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
17
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
18
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
19
|
+
'warranty_uuid' => $this->when(Http::isInternalRequest(), $this->warranty_uuid),
|
|
20
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
21
|
+
'equipable_uuid' => $this->when(Http::isInternalRequest(), $this->equipable_uuid),
|
|
22
|
+
'equipable_type' => $this->when(Http::isInternalRequest(), $this->equipable_type ? Utils::toEmberResourceType($this->equipable_type) : null),
|
|
23
|
+
'warranty' => $this->whenLoaded('warranty', fn () => $this->resolveLoadedRelation($this->warranty)),
|
|
24
|
+
'photo' => $this->whenLoaded('photo', fn () => $this->resolveLoadedRelation($this->photo)),
|
|
25
|
+
'equipable' => $this->whenLoaded('equipable', fn () => $this->resolveLoadedRelation($this->equipable)),
|
|
26
|
+
'name' => $this->name,
|
|
27
|
+
'code' => $this->code,
|
|
28
|
+
'type' => $this->type,
|
|
29
|
+
'status' => $this->status,
|
|
30
|
+
'serial_number' => $this->serial_number,
|
|
31
|
+
'manufacturer' => $this->manufacturer,
|
|
32
|
+
'model' => $this->model,
|
|
33
|
+
'purchased_at' => $this->purchased_at,
|
|
34
|
+
'purchase_price' => $this->purchase_price,
|
|
35
|
+
'currency' => $this->currency,
|
|
36
|
+
'warranty_name' => $this->warranty_name,
|
|
37
|
+
'photo_url' => $this->photo_url,
|
|
38
|
+
'equipped_to_name' => $this->equipped_to_name,
|
|
39
|
+
'is_equipped' => $this->is_equipped,
|
|
40
|
+
'age_in_days' => $this->age_in_days,
|
|
41
|
+
'depreciated_value' => $this->depreciated_value,
|
|
42
|
+
'meta' => data_get($this, 'meta', Utils::createObject()),
|
|
43
|
+
'slug' => $this->slug,
|
|
44
|
+
'updated_at' => $this->updated_at,
|
|
45
|
+
'created_at' => $this->created_at,
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
protected function resolveLoadedRelation($model)
|
|
50
|
+
{
|
|
51
|
+
if (!$model) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return Http::isInternalRequest() ? Resolve::httpResourceForModel($model) : $model->public_id;
|
|
56
|
+
}
|
|
57
|
+
}
|