@fleetbase/fleetops-engine 0.6.16 → 0.6.18
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/layout/fleet-ops-sidebar.hbs +25 -0
- package/addon/templates/virtual.hbs +3 -3
- package/composer.json +3 -2
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/migrations/2025_08_11_170800_add_company_index_to_routes_table.php +21 -0
- package/server/migrations/2025_08_28_054920_create_warranties_table.php +56 -0
- package/server/migrations/2025_08_28_054921_create_telematics_table.php +60 -0
- package/server/migrations/2025_08_28_054922_create_assets_table.php +94 -0
- package/server/migrations/2025_08_28_054925_create_devices_table.php +190 -0
- package/server/migrations/2025_08_28_054926_create_device_events_table.php +99 -0
- package/server/migrations/2025_08_28_054926_create_sensors_table.php +62 -0
- package/server/migrations/2025_08_28_054927_create_parts_table.php +73 -0
- package/server/migrations/2025_08_28_054929_create_equipments_table.php +58 -0
- package/server/migrations/2025_08_28_054930_create_work_orders_table.php +85 -0
- package/server/migrations/2025_08_28_054931_create_maintenances_table.php +79 -0
- package/server/migrations/2025_08_28_082002_update_vehicles_table_telematics.php +60 -0
- package/server/src/Http/Controllers/Api/v1/OrderController.php +19 -1
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +31 -8
- package/server/src/Http/Resources/v1/Order.php +111 -60
- package/server/src/Models/Asset.php +548 -0
- package/server/src/Models/Contact.php +2 -0
- package/server/src/Models/Device.php +435 -0
- package/server/src/Models/DeviceEvent.php +501 -0
- package/server/src/Models/Driver.php +2 -0
- package/server/src/Models/Entity.php +27 -50
- package/server/src/Models/Equipment.php +483 -0
- package/server/src/Models/Fleet.php +2 -0
- package/server/src/Models/FuelReport.php +2 -0
- package/server/src/Models/Issue.php +2 -0
- package/server/src/Models/Maintenance.php +549 -0
- package/server/src/Models/Order.php +32 -112
- package/server/src/Models/OrderConfig.php +8 -0
- package/server/src/Models/Part.php +502 -0
- package/server/src/Models/Payload.php +101 -20
- package/server/src/Models/Place.php +10 -4
- package/server/src/Models/Sensor.php +510 -0
- package/server/src/Models/ServiceArea.php +1 -1
- package/server/src/Models/Telematic.php +336 -0
- package/server/src/Models/Vehicle.php +45 -1
- package/server/src/Models/VehicleDevice.php +1 -1
- package/server/src/Models/Vendor.php +2 -0
- package/server/src/Models/Warranty.php +413 -0
- package/server/src/Models/Waypoint.php +2 -0
- package/server/src/Models/WorkOrder.php +532 -0
- package/server/src/Support/Utils.php +5 -0
- package/server/src/Traits/HasTrackingNumber.php +64 -10
- package/server/src/Traits/Maintainable.php +307 -0
- package/server/src/Traits/PayloadAccessors.php +126 -0
|
@@ -15,68 +15,119 @@ class Order extends FleetbaseResource
|
|
|
15
15
|
* Transform the resource into an array.
|
|
16
16
|
*
|
|
17
17
|
* @param \Illuminate\Http\Request $request
|
|
18
|
-
*
|
|
19
|
-
* @return array
|
|
20
18
|
*/
|
|
21
|
-
public function toArray($request)
|
|
19
|
+
public function toArray($request): array
|
|
22
20
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
|
|
21
|
+
$isInternal = Http::isInternalRequest();
|
|
22
|
+
$isPublic = Http::isPublicRequest();
|
|
23
|
+
|
|
24
|
+
// Precompute expensive bits safely
|
|
25
|
+
$orderConfigPublicId = data_get($this->orderConfig, 'public_id');
|
|
26
|
+
|
|
27
|
+
// Driver / vehicle relations (prevent eager noise)
|
|
28
|
+
$driverAssignedModel = $this->driverAssigned()->without(['jobs', 'currentJob'])->first();
|
|
29
|
+
$vehicleAssignedModel = $this->vehicleAssigned()->without(['fleets', 'vendor'])->first();
|
|
30
|
+
|
|
31
|
+
// Tracker helpers (avoid calling ->tracker() twice)
|
|
32
|
+
$withTrackerData = $request->has('with_tracker_data') || !empty($this->resource->tracker_data);
|
|
33
|
+
$withEta = $request->has('with_eta') || !empty($this->resource->eta);
|
|
34
|
+
$tracker = ($withTrackerData || $withEta) ? $this->resource->tracker() : null;
|
|
35
|
+
|
|
36
|
+
return $this->withCustomFields([
|
|
37
|
+
// IDs
|
|
38
|
+
'id' => $this->when($isInternal, $this->id, $this->public_id),
|
|
39
|
+
'uuid' => $this->when($isInternal, $this->uuid),
|
|
40
|
+
'public_id' => $this->when($isInternal, $this->public_id),
|
|
41
|
+
'internal_id' => $this->internal_id,
|
|
42
|
+
|
|
43
|
+
// FKs (internal only)
|
|
44
|
+
'company_uuid' => $this->when($isInternal, $this->company_uuid),
|
|
45
|
+
'transaction_uuid' => $this->when($isInternal, $this->transaction_uuid),
|
|
46
|
+
'customer_uuid' => $this->when($isInternal, $this->customer_uuid),
|
|
47
|
+
'customer_type' => $this->when($isInternal, $this->customer_type),
|
|
48
|
+
'facilitator_uuid' => $this->when($isInternal, $this->facilitator_uuid),
|
|
49
|
+
'facilitator_type' => $this->when($isInternal, $this->facilitator_type),
|
|
50
|
+
'payload_uuid' => $this->when($isInternal, $this->payload_uuid),
|
|
51
|
+
'route_uuid' => $this->when($isInternal, $this->route_uuid),
|
|
52
|
+
'purchase_rate_uuid' => $this->when($isInternal, $this->purchase_rate_uuid),
|
|
53
|
+
'tracking_number_uuid' => $this->when($isInternal, $this->tracking_number_uuid),
|
|
54
|
+
'driver_assigned_uuid' => $this->when($isInternal, $this->driver_assigned_uuid),
|
|
55
|
+
'vehicle_assigned_uuid'=> $this->when($isInternal, $this->vehicle_assigned_uuid),
|
|
56
|
+
'service_quote_uuid' => $this->when($isInternal, $this->service_quote_uuid),
|
|
57
|
+
'has_driver_assigned' => $this->when($isInternal, $this->has_driver_assigned),
|
|
58
|
+
'is_scheduled' => $this->when($isInternal, $this->is_scheduled),
|
|
59
|
+
|
|
60
|
+
// Order config: internal gets the relation; public gets the public_id (or null)
|
|
61
|
+
'order_config_uuid' => $this->when($isInternal, $this->order_config_uuid),
|
|
62
|
+
'order_config' => $this->when(
|
|
63
|
+
$isInternal,
|
|
64
|
+
$this->whenLoaded('orderConfig', function () {
|
|
65
|
+
return $this->orderConfig;
|
|
66
|
+
}),
|
|
67
|
+
$orderConfigPublicId
|
|
68
|
+
),
|
|
69
|
+
|
|
70
|
+
// Custom field values (internal only) — the relation collection is fine for internal,
|
|
71
|
+
// public callers will not see this key at all
|
|
72
|
+
'custom_field_values' => $this->when($isInternal, $this->customFieldValues),
|
|
73
|
+
|
|
74
|
+
// Morph resources
|
|
75
|
+
'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
|
|
76
|
+
'payload' => new Payload($this->payload),
|
|
77
|
+
'facilitator' => $this->setFacilitatorType(Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid)),
|
|
78
|
+
|
|
79
|
+
// Assigned entities
|
|
80
|
+
'driver_assigned' => new Driver($driverAssignedModel),
|
|
81
|
+
'vehicle_assigned' => new Vehicle($vehicleAssignedModel),
|
|
82
|
+
|
|
83
|
+
// Tracking
|
|
84
|
+
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
85
|
+
'tracking_statuses' => $this->whenLoaded('trackingStatuses', function () {
|
|
86
|
+
return TrackingStatus::collection($this->trackingStatuses);
|
|
87
|
+
}),
|
|
88
|
+
'tracking' => $this->when($isInternal, $this->trackingNumber ? $this->trackingNumber->tracking_number : null),
|
|
89
|
+
'barcode' => $this->when($isInternal, $this->trackingNumber ? $this->trackingNumber->barcode : null),
|
|
90
|
+
'qr_code' => $this->when($isInternal, $this->trackingNumber ? $this->trackingNumber->qr_code : null),
|
|
91
|
+
|
|
92
|
+
// Comments & files (internal gets raw; public gets resource collections)
|
|
93
|
+
'comments' => $this->when($isInternal, Comment::collection($this->comments)),
|
|
94
|
+
'files' => $this->when($isInternal, $this->files, File::collection($this->files)),
|
|
95
|
+
|
|
96
|
+
// Pricing / notes
|
|
97
|
+
'purchase_rate' => new PurchaseRate($this->purchaseRate),
|
|
98
|
+
'notes' => $this->notes,
|
|
99
|
+
|
|
100
|
+
// Expose only keys list publicly
|
|
101
|
+
'custom_fields' => $this->when($isPublic, function () {
|
|
102
|
+
return $this->getCustomFieldKeys();
|
|
103
|
+
}),
|
|
104
|
+
|
|
105
|
+
// Basic attrs
|
|
106
|
+
'type' => $this->type,
|
|
107
|
+
'status' => $this->status,
|
|
108
|
+
'pod_method' => $this->pod_method,
|
|
109
|
+
'pod_required' => (bool) data_get($this, 'pod_required', false),
|
|
110
|
+
'dispatched' => (bool) data_get($this, 'dispatched', false),
|
|
111
|
+
'adhoc' => (bool) data_get($this, 'adhoc', false),
|
|
112
|
+
'adhoc_distance' => (int) $this->getAdhocDistance(),
|
|
113
|
+
'distance' => (int) $this->distance,
|
|
114
|
+
'time' => (int) $this->time,
|
|
115
|
+
|
|
116
|
+
// Tracker derived data (computed only when requested/present)
|
|
117
|
+
'tracker_data' => $this->when($withTrackerData, function () use ($tracker) {
|
|
118
|
+
return $this->resource->tracker_data ?? ($tracker ? $tracker->toArray() : null);
|
|
119
|
+
}),
|
|
120
|
+
'eta' => $this->when($withEta, function () use ($tracker) {
|
|
121
|
+
return $this->resource->eta ?? ($tracker ? $tracker->eta() : null);
|
|
122
|
+
}),
|
|
123
|
+
|
|
124
|
+
'meta' => data_get($this, 'meta', Utils::createObject()),
|
|
125
|
+
'dispatched_at' => $this->dispatched_at,
|
|
126
|
+
'started_at' => $this->started_at,
|
|
127
|
+
'scheduled_at' => $this->scheduled_at,
|
|
128
|
+
'updated_at' => $this->updated_at,
|
|
129
|
+
'created_at' => $this->created_at,
|
|
130
|
+
]);
|
|
80
131
|
}
|
|
81
132
|
|
|
82
133
|
/**
|