@fleetbase/fleetops-engine 0.6.28 → 0.6.30

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.
Files changed (92) hide show
  1. package/addon/components/customer/create-order-form.hbs +1 -1
  2. package/addon/components/customer/order-form.hbs +34 -34
  3. package/addon/components/customer/orders.hbs +2 -2
  4. package/addon/components/display-place.hbs +1 -1
  5. package/addon/components/driver/pill.hbs +16 -17
  6. package/addon/components/driver/pill.js +5 -1
  7. package/addon/components/map/leaflet-live-map.js +35 -3
  8. package/addon/components/map/order-list-overlay/order.hbs +1 -0
  9. package/addon/components/map/order-list-overlay/order.js +42 -0
  10. package/addon/components/modals/bulk-assign-driver.hbs +2 -2
  11. package/addon/components/order/details/detail.hbs +6 -6
  12. package/addon/components/order/details/notes.js +1 -1
  13. package/addon/components/order/route-editor.hbs +3 -3
  14. package/addon/components/order-tracking-lookup.hbs +1 -1
  15. package/addon/components/service-rate/details.hbs +117 -75
  16. package/addon/components/service-rate/form.hbs +7 -4
  17. package/addon/components/service-rate/form.js +6 -0
  18. package/addon/components/vehicle/pill.hbs +32 -33
  19. package/addon/components/vehicle/pill.js +5 -1
  20. package/addon/controllers/operations/orders/index.js +1 -1
  21. package/addon/controllers/operations/scheduler/index.js +17 -2
  22. package/addon/controllers/operations/service-rates/index/edit.js +1 -7
  23. package/addon/controllers/operations/service-rates/index/new.js +0 -7
  24. package/addon/controllers/operations/service-rates/index.js +10 -2
  25. package/addon/routes/operations/orders/index/details.js +7 -0
  26. package/addon/routes/operations/scheduler/index.js +3 -3
  27. package/addon/services/driver-actions.js +20 -4
  28. package/addon/services/leaflet-routing-control.js +7 -1
  29. package/addon/services/order-list-overlay.js +0 -1
  30. package/addon/services/place-actions.js +20 -4
  31. package/addon/services/service-rate-actions.js +31 -0
  32. package/addon/services/vehicle-actions.js +20 -4
  33. package/addon/templates/operations/scheduler/index.hbs +2 -2
  34. package/addon/utils/create-full-calendar-event-from-order.js +6 -0
  35. package/composer.json +1 -1
  36. package/extension.json +1 -1
  37. package/index.js +0 -11
  38. package/package.json +4 -4
  39. package/server/migrations/2025_12_16_000001_add_subject_created_at_index_to_positions.php +40 -0
  40. package/server/migrations/2025_12_16_000003_add_performance_indexes_to_fleetops_core_tables.php +442 -0
  41. package/server/src/Console/Commands/DispatchAdhocOrders.php +7 -2
  42. package/server/src/Http/Controllers/Api/v1/DriverController.php +2 -0
  43. package/server/src/Http/Controllers/Api/v1/OrderController.php +30 -0
  44. package/server/src/Http/Controllers/Internal/v1/LiveController.php +184 -86
  45. package/server/src/Http/Controllers/Internal/v1/OrderController.php +14 -1
  46. package/server/src/Http/Controllers/Internal/v1/PlaceController.php +5 -0
  47. package/server/src/Http/Filter/DriverFilter.php +10 -0
  48. package/server/src/Http/Filter/OrderFilter.php +8 -1
  49. package/server/src/Http/Resources/v1/Contact.php +2 -2
  50. package/server/src/Http/Resources/v1/Entity.php +1 -1
  51. package/server/src/Http/Resources/v1/Index/Customer.php +33 -0
  52. package/server/src/Http/Resources/v1/Index/Driver.php +45 -0
  53. package/server/src/Http/Resources/v1/Index/Facilitator.php +33 -0
  54. package/server/src/Http/Resources/v1/Index/Order.php +127 -0
  55. package/server/src/Http/Resources/v1/Index/Payload.php +57 -0
  56. package/server/src/Http/Resources/v1/Index/Place.php +45 -0
  57. package/server/src/Http/Resources/v1/Index/TrackingNumber.php +25 -0
  58. package/server/src/Http/Resources/v1/Index/Vehicle.php +50 -0
  59. package/server/src/Http/Resources/v1/Order.php +41 -14
  60. package/server/src/Http/Resources/v1/Place.php +1 -1
  61. package/server/src/Http/Resources/v1/Position.php +2 -1
  62. package/server/src/Http/Resources/v1/ServiceRate.php +4 -4
  63. package/server/src/Http/Resources/v1/ServiceRateFee.php +12 -12
  64. package/server/src/Http/Resources/v1/ServiceRateParcelFee.php +14 -7
  65. package/server/src/Http/Resources/v1/TrackingNumber.php +1 -1
  66. package/server/src/Http/Resources/v1/Waypoint.php +1 -1
  67. package/server/src/Listeners/HandleOrderDispatched.php +5 -0
  68. package/server/src/Models/Contact.php +2 -0
  69. package/server/src/Models/Device.php +2 -0
  70. package/server/src/Models/DeviceEvent.php +2 -0
  71. package/server/src/Models/Driver.php +2 -0
  72. package/server/src/Models/FuelReport.php +2 -0
  73. package/server/src/Models/Issue.php +2 -0
  74. package/server/src/Models/Order.php +12 -5
  75. package/server/src/Models/Place.php +2 -0
  76. package/server/src/Models/Position.php +2 -0
  77. package/server/src/Models/ServiceArea.php +2 -0
  78. package/server/src/Models/ServiceRate.php +5 -1
  79. package/server/src/Models/ServiceRateFee.php +3 -17
  80. package/server/src/Models/ServiceRateParcelFee.php +1 -12
  81. package/server/src/Models/Vehicle.php +2 -0
  82. package/server/src/Models/Vendor.php +2 -0
  83. package/server/src/Models/Zone.php +2 -0
  84. package/server/src/Observers/DriverObserver.php +23 -0
  85. package/server/src/Observers/OrderObserver.php +31 -0
  86. package/server/src/Observers/PlaceObserver.php +31 -0
  87. package/server/src/Observers/ServiceRateObserver.php +0 -18
  88. package/server/src/Observers/VehicleObserver.php +7 -0
  89. package/server/src/Support/LiveCacheService.php +165 -0
  90. package/server/src/Support/OSRM.php +49 -22
  91. package/server/src/Support/OrderTracker.php +100 -28
  92. package/translations/en-us.yaml +3 -1
@@ -0,0 +1,127 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1\Index;
4
+
5
+ use Fleetbase\FleetOps\Support\Utils;
6
+ use Fleetbase\Http\Resources\FleetbaseResource;
7
+ use Fleetbase\Support\Http;
8
+
9
+ /**
10
+ * Lightweight Order resource optimized for index/list views.
11
+ * This resource includes only the essential data needed to display orders in a table,
12
+ * significantly reducing payload size and improving response times.
13
+ */
14
+ class Order extends FleetbaseResource
15
+ {
16
+ /**
17
+ * Transform the resource into an array.
18
+ *
19
+ * @param \Illuminate\Http\Request $request
20
+ */
21
+ public function toArray($request): array
22
+ {
23
+ $isInternal = Http::isInternalRequest();
24
+
25
+ return [
26
+ 'id' => $this->when($isInternal, $this->id, $this->public_id),
27
+ 'uuid' => $this->when($isInternal, $this->uuid),
28
+ 'public_id' => $this->when($isInternal, $this->public_id),
29
+ 'internal_id' => $this->internal_id,
30
+ 'company_uuid' => $this->when($isInternal, $this->company_uuid),
31
+ 'payload_uuid' => $this->when($isInternal, $this->payload_uuid),
32
+ 'driver_assigned_uuid' => $this->when($isInternal, $this->driver_assigned_uuid),
33
+ 'vehicle_assigned_uuid'=> $this->when($isInternal, $this->vehicle_assigned_uuid),
34
+ 'customer_uuid' => $this->when($isInternal, $this->customer_uuid),
35
+ 'customer_type' => $this->when($isInternal, $this->customer_type),
36
+ 'facilitator_uuid' => $this->when($isInternal, $this->facilitator_uuid),
37
+ 'facilitator_type' => $this->when($isInternal, $this->facilitator_type),
38
+ 'tracking_number_uuid' => $this->when($isInternal, $this->tracking_number_uuid),
39
+ 'order_config_uuid' => $this->when($isInternal, $this->order_config_uuid),
40
+ 'tracking' => $this->trackingNumber ? $this->trackingNumber->tracking_number : null,
41
+
42
+ // Minimal order config - only essential fields
43
+ 'order_config' => $this->when(
44
+ $isInternal,
45
+ $this->whenLoaded('orderConfig', function () {
46
+ return [
47
+ 'id' => $this->orderConfig->public_id,
48
+ 'name' => $this->orderConfig->name,
49
+ 'key' => $this->orderConfig->key,
50
+ ];
51
+ })
52
+ ),
53
+
54
+ // Lightweight customer
55
+ 'customer' => $this->whenLoaded('customer', function () {
56
+ $resource = new Customer($this->customer);
57
+ $data = $resource->resolve();
58
+ data_set($data, 'type', 'customer');
59
+ data_set($data, 'customer_type', 'customer-' . Utils::toEmberResourceType($this->customer_type));
60
+
61
+ return $data;
62
+ }),
63
+
64
+ // Lightweight payload
65
+ 'payload' => $this->whenLoaded('payload', function () {
66
+ return new Payload($this->payload);
67
+ }),
68
+
69
+ // Lightweight facilitator
70
+ 'facilitator' => $this->whenLoaded('facilitator', function () {
71
+ $resource = new Facilitator($this->facilitator);
72
+ $data = $resource->resolve();
73
+ data_set($data, 'type', 'facilitator');
74
+ data_set($data, 'facilitator_type', 'facilitator-' . Utils::toEmberResourceType($this->facilitator_type));
75
+
76
+ return $data;
77
+ }),
78
+
79
+ // Lightweight driver
80
+ 'driver_assigned' => $this->whenLoaded('driverAssigned', function () {
81
+ return new Driver($this->driverAssigned);
82
+ }),
83
+
84
+ // Lightweight vehicle
85
+ 'vehicle_assigned' => $this->whenLoaded('vehicleAssigned', function () {
86
+ return new Vehicle($this->vehicleAssigned);
87
+ }),
88
+
89
+ // Lightweight tracking number with QR code
90
+ 'tracking_number' => $this->whenLoaded('trackingNumber', function () {
91
+ return new TrackingNumber($this->trackingNumber);
92
+ }),
93
+
94
+ // Latest status only, not full array
95
+ 'latest_status' => $this->whenLoaded('trackingStatuses', function () {
96
+ $latest = $this->trackingStatuses->first();
97
+
98
+ return $latest ? $latest->status : 'created';
99
+ }),
100
+ 'latest_status_code' => $this->whenLoaded('trackingStatuses', function () {
101
+ $latest = $this->trackingStatuses->first();
102
+
103
+ return $latest ? $latest->code : null;
104
+ }),
105
+
106
+ // Essential scalar fields
107
+ 'type' => $this->type,
108
+ 'status' => $this->status,
109
+ 'adhoc' => (bool) data_get($this, 'adhoc', false),
110
+ 'dispatched' => (bool) data_get($this, 'dispatched', false),
111
+ 'has_driver_assigned' => $this->when($isInternal, $this->has_driver_assigned),
112
+ 'is_scheduled' => $this->when($isInternal, $this->is_scheduled),
113
+
114
+ // Timestamps
115
+ 'scheduled_at' => $this->scheduled_at,
116
+ 'dispatched_at' => $this->dispatched_at,
117
+ 'started_at' => $this->started_at,
118
+ 'created_at' => $this->created_at,
119
+ 'updated_at' => $this->updated_at,
120
+
121
+ // Meta flag to indicate this is an index resource
122
+ 'meta' => [
123
+ '_index_resource' => true,
124
+ ],
125
+ ];
126
+ }
127
+ }
@@ -0,0 +1,57 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1\Index;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ /**
9
+ * Lightweight Payload resource for index views.
10
+ * Only includes essential pickup/dropoff information and entity count.
11
+ */
12
+ class Payload extends FleetbaseResource
13
+ {
14
+ /**
15
+ * Transform the resource into an array.
16
+ *
17
+ * @param \Illuminate\Http\Request $request
18
+ */
19
+ public function toArray($request): array
20
+ {
21
+ $isInternal = Http::isInternalRequest();
22
+
23
+ return [
24
+ 'id' => $this->when($isInternal, $this->id, $this->public_id),
25
+ 'uuid' => $this->when($isInternal, $this->uuid),
26
+ 'public_id' => $this->when($isInternal, $this->public_id),
27
+ 'company_uuid' => $this->when($isInternal, $this->company_uuid),
28
+ 'pickup_uuid' => $this->when($isInternal, $this->pickup_uuid),
29
+ 'dropoff_uuid' => $this->when($isInternal, $this->dropoff_uuid),
30
+ 'return_uuid' => $this->when($isInternal, $this->return_uuid),
31
+
32
+ // Minimal pickup - only what's displayed in the table
33
+ 'pickup' => $this->whenLoaded('pickup', function () {
34
+ return new Place($this->pickup);
35
+ }),
36
+
37
+ // Minimal dropoff - only what's displayed in the table
38
+ 'dropoff' => $this->whenLoaded('dropoff', function () {
39
+ return new Place($this->dropoff);
40
+ }),
41
+
42
+ // Entity count instead of full entities
43
+ 'entities_count' => $this->whenLoaded('entities', function () {
44
+ return $this->entities->count();
45
+ }),
46
+
47
+ // Waypoint count instead of full waypoints
48
+ 'waypoints_count' => $this->whenLoaded('waypoints', function () {
49
+ return $this->waypoints->count();
50
+ }),
51
+
52
+ 'type' => $this->type,
53
+ 'created_at' => $this->created_at,
54
+ 'updated_at' => $this->updated_at,
55
+ ];
56
+ }
57
+ }
@@ -0,0 +1,45 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1\Index;
4
+
5
+ use Fleetbase\FleetOps\Support\Utils;
6
+ use Fleetbase\Http\Resources\FleetbaseResource;
7
+ use Fleetbase\Support\Http;
8
+
9
+ /**
10
+ * Lightweight Place resource for index views.
11
+ * Only includes name, address, and location coordinates.
12
+ */
13
+ class Place extends FleetbaseResource
14
+ {
15
+ /**
16
+ * Transform the resource into an array.
17
+ *
18
+ * @param \Illuminate\Http\Request $request
19
+ */
20
+ public function toArray($request): array
21
+ {
22
+ $isInternal = Http::isInternalRequest();
23
+
24
+ return [
25
+ 'id' => $this->when($isInternal, $this->id, $this->public_id),
26
+ 'uuid' => $this->when($isInternal, $this->uuid),
27
+ 'public_id' => $this->when($isInternal, $this->public_id),
28
+ 'company_uuid' => $this->when($isInternal, $this->company_uuid),
29
+ 'owner_uuid' => $this->when($isInternal, $this->owner_uuid),
30
+ 'owner_type' => $this->when($isInternal, $this->owner_type),
31
+ 'name' => $this->name,
32
+ 'address' => $this->address,
33
+ 'street1' => $this->street1,
34
+ 'city' => $this->city,
35
+ 'country' => $this->country,
36
+ 'avatar_url' => $this->avatar_url,
37
+ 'location' => Utils::getPointFromMixed($this->location),
38
+
39
+ // Meta flag to indicate this is an index resource
40
+ 'meta' => [
41
+ '_index_resource' => true,
42
+ ],
43
+ ];
44
+ }
45
+ }
@@ -0,0 +1,25 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1\Index;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+
7
+ class TrackingNumber extends FleetbaseResource
8
+ {
9
+ /**
10
+ * Transform the resource into an array.
11
+ *
12
+ * @param \Illuminate\Http\Request $request
13
+ *
14
+ * @return array
15
+ */
16
+ public function toArray($request)
17
+ {
18
+ return [
19
+ 'id' => $this->when($this->id, $this->id),
20
+ 'uuid' => $this->when($this->uuid, $this->uuid),
21
+ 'tracking_number' => $this->when($this->tracking_number, $this->tracking_number),
22
+ 'qr_code' => $this->when($this->qr_code, $this->qr_code),
23
+ ];
24
+ }
25
+ }
@@ -0,0 +1,50 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1\Index;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\LaravelMysqlSpatial\Types\Point;
7
+ use Fleetbase\Support\Http;
8
+
9
+ /**
10
+ * Lightweight Vehicle resource for index views.
11
+ * Only includes essential identification and display information.
12
+ */
13
+ class Vehicle extends FleetbaseResource
14
+ {
15
+ /**
16
+ * Transform the resource into an array.
17
+ *
18
+ * @param \Illuminate\Http\Request $request
19
+ */
20
+ public function toArray($request): array
21
+ {
22
+ $isInternal = Http::isInternalRequest();
23
+
24
+ return [
25
+ 'id' => $this->when($isInternal, $this->id, $this->public_id),
26
+ 'uuid' => $this->when($isInternal, $this->uuid),
27
+ 'public_id' => $this->when($isInternal, $this->public_id),
28
+ 'company_uuid' => $this->when($isInternal, $this->company_uuid),
29
+ 'vendor_uuid' => $this->when($isInternal, $this->vendor_uuid),
30
+ 'photo_uuid' => $this->when($isInternal, $this->photo_uuid),
31
+ 'display_name' => $this->display_name,
32
+ 'plate_number' => $this->plate_number,
33
+ 'make' => $this->make,
34
+ 'model' => $this->model,
35
+ 'year' => $this->year,
36
+ 'photo_url' => $this->photo_url,
37
+ 'status' => $this->status,
38
+ 'location' => data_get($this, 'location', new Point(0, 0)),
39
+ 'heading' => (int) data_get($this, 'heading', 0),
40
+ 'altitude' => (int) data_get($this, 'altitude', 0),
41
+ 'speed' => (int) data_get($this, 'speed', 0),
42
+ 'online' => (bool) data_get($this, 'online', false),
43
+
44
+ // Meta flag to indicate this is an index resource
45
+ 'meta' => [
46
+ '_index_resource' => true,
47
+ ],
48
+ ];
49
+ }
50
+ }
@@ -7,7 +7,6 @@ use Fleetbase\Http\Resources\Comment;
7
7
  use Fleetbase\Http\Resources\File;
8
8
  use Fleetbase\Http\Resources\FleetbaseResource;
9
9
  use Fleetbase\Support\Http;
10
- use Fleetbase\Support\Resolve;
11
10
 
12
11
  class Order extends FleetbaseResource
13
12
  {
@@ -19,15 +18,10 @@ class Order extends FleetbaseResource
19
18
  public function toArray($request): array
20
19
  {
21
20
  $isInternal = Http::isInternalRequest();
22
- $isPublic = Http::isPublicRequest();
23
21
 
24
22
  // Precompute expensive bits safely
25
23
  $orderConfigPublicId = data_get($this->orderConfig, 'public_id');
26
24
 
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
25
  // Tracker helpers (avoid calling ->tracker() twice)
32
26
  $withTrackerData = $request->has('with_tracker_data') || !empty($this->resource->tracker_data);
33
27
  $withEta = $request->has('with_eta') || !empty($this->resource->eta);
@@ -41,9 +35,9 @@ class Order extends FleetbaseResource
41
35
  'company_uuid' => $this->when($isInternal, $this->company_uuid),
42
36
  'transaction_uuid' => $this->when($isInternal, $this->transaction_uuid),
43
37
  'customer_uuid' => $this->when($isInternal, $this->customer_uuid),
44
- 'customer_type' => $this->when($isInternal, $this->customer_type),
38
+ 'customer_type' => $this->when($isInternal, $this->customer_type ? Utils::toEmberResourceType($this->customer_type) : null),
45
39
  'facilitator_uuid' => $this->when($isInternal, $this->facilitator_uuid),
46
- 'facilitator_type' => $this->when($isInternal, $this->facilitator_type),
40
+ 'facilitator_type' => $this->when($isInternal, $this->facilitator_type ? Utils::toEmberResourceType($this->facilitator_type) : null),
47
41
  'payload_uuid' => $this->when($isInternal, $this->payload_uuid),
48
42
  'route_uuid' => $this->when($isInternal, $this->route_uuid),
49
43
  'purchase_rate_uuid' => $this->when($isInternal, $this->purchase_rate_uuid),
@@ -61,11 +55,19 @@ class Order extends FleetbaseResource
61
55
  }),
62
56
  $orderConfigPublicId
63
57
  ),
64
- 'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
58
+ 'customer' => $this->whenLoaded('customer', function () {
59
+ return $this->setCustomerType($this->transformMorphResource($this->customer));
60
+ }),
65
61
  'payload' => new Payload($this->payload),
66
- 'facilitator' => $this->setFacilitatorType(Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid)),
67
- 'driver_assigned' => new Driver($driverAssignedModel),
68
- 'vehicle_assigned' => new Vehicle($vehicleAssignedModel),
62
+ 'facilitator' => $this->whenLoaded('facilitator', function () {
63
+ return $this->setFacilitatorType($this->transformMorphResource($this->facilitator));
64
+ }),
65
+ 'driver_assigned' => $this->whenLoaded('driverAssigned', function () {
66
+ return new Driver($this->driverAssigned);
67
+ }),
68
+ 'vehicle_assigned' => $this->whenLoaded('vehicleAssigned', function () {
69
+ return new Vehicle($this->vehicleAssigned);
70
+ }),
69
71
  'tracking_number' => new TrackingNumber($this->trackingNumber),
70
72
  'tracking_statuses' => $this->whenLoaded('trackingStatuses', function () {
71
73
  return TrackingStatus::collection($this->trackingStatuses);
@@ -139,6 +141,31 @@ class Order extends FleetbaseResource
139
141
  return $resolved;
140
142
  }
141
143
 
144
+ /**
145
+ * Transform a polymorphic relationship into its appropriate resource.
146
+ * This method dynamically resolves the resource class based on the model type.
147
+ *
148
+ * @param \Illuminate\Database\Eloquent\Model|null $model
149
+ *
150
+ * @return array|null
151
+ */
152
+ protected function transformMorphResource($model)
153
+ {
154
+ if (!$model) {
155
+ return null;
156
+ }
157
+
158
+ // Use Find to get the appropriate resource class for this model
159
+ $resourceClass = \Fleetbase\Support\Find::httpResourceForModel($model);
160
+
161
+ if ($resourceClass) {
162
+ return (new $resourceClass($model))->resolve();
163
+ }
164
+
165
+ // Fallback to generic resource
166
+ return (new \Illuminate\Http\Resources\Json\JsonResource($model))->resolve();
167
+ }
168
+
142
169
  /**
143
170
  * Transform the resource into an webhook payload.
144
171
  *
@@ -149,9 +176,9 @@ class Order extends FleetbaseResource
149
176
  return [
150
177
  'id' => $this->public_id,
151
178
  'internal_id' => $this->internal_id,
152
- 'customer' => Resolve::resourceForMorph($this->customer_type, $this->customer_uuid),
179
+ 'customer' => $this->transformMorphResource($this->customer),
153
180
  'payload' => new Payload($this->payload),
154
- 'facilitator' => Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid),
181
+ 'facilitator' => $this->transformMorphResource($this->facilitator),
155
182
  'driver_assigned' => new Driver($this->driverAssigned),
156
183
  'tracking_number' => new TrackingNumber($this->trackingNumber),
157
184
  'purchase_rate' => new PurchaseRate($this->purchaseRate),
@@ -26,7 +26,7 @@ class Place extends FleetbaseResource
26
26
  'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
27
27
  'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
28
28
  'owner_uuid' => $this->when(Http::isInternalRequest(), $this->owner_uuid),
29
- 'owner_type' => $this->when(Http::isInternalRequest(), $this->owner_type),
29
+ 'owner_type' => $this->when(Http::isInternalRequest(), $this->owner_type ? Utils::toEmberResourceType($this->owner_type) : null),
30
30
  'name' => $this->name,
31
31
  'location' => Utils::getPointFromMixed($this->location),
32
32
  'address' => $this->address,
@@ -2,6 +2,7 @@
2
2
 
3
3
  namespace Fleetbase\FleetOps\Http\Resources\v1;
4
4
 
5
+ use Fleetbase\FleetOps\Support\Utils;
5
6
  use Fleetbase\Http\Resources\FleetbaseResource;
6
7
  use Fleetbase\LaravelMysqlSpatial\Types\Point;
7
8
  use Fleetbase\Support\Http;
@@ -26,7 +27,7 @@ class Position extends FleetbaseResource
26
27
  'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
27
28
  'destination_uuid' => $this->when(Http::isInternalRequest(), $this->destination_uuid),
28
29
  'subject_uuid' => $this->when(Http::isInternalRequest(), $this->subject_uuid),
29
- 'subject_type' => $this->subject_type,
30
+ 'subject_type' => $this->subject_type ? Utils::toEmberResourceType($this->subject_type) : null,
30
31
  'subject' => $this->whenLoaded('subject', fn () => Resolve::httpResourceForModel($this->subject)),
31
32
  'order' => $this->whenLoaded('order', fn () => new Order($this->order)),
32
33
  'destination' => $this->whenLoaded('destination', fn () => new Place($this->destination)),
@@ -45,8 +45,8 @@ class ServiceRate extends FleetbaseResource
45
45
  'per_meter_unit' => $this->per_meter_unit,
46
46
  'max_distance_unit' => $this->max_distance_unit,
47
47
  'max_distance' => $this->max_distance,
48
- 'meter_fees' => ServiceRateFee::collection($this->rateFees ?? []),
49
- 'parcel_fees' => ServiceRateParcelFee::collection($this->rateFees ?? []),
48
+ 'rate_fees' => ServiceRateFee::collection($this->rateFees ?? []),
49
+ 'parcel_fees' => ServiceRateParcelFee::collection($this->parcelFees ?? []),
50
50
  'algorithm' => $this->algorithm,
51
51
  'has_cod_fee' => Utils::castBoolean($this->has_cod_fee),
52
52
  'cod_calculation_method' => $this->cod_calculation_method,
@@ -82,8 +82,8 @@ class ServiceRate extends FleetbaseResource
82
82
  'base_fee' => $this->base_fee,
83
83
  'rate_calculation_method' => $this->rate_calculation_method,
84
84
  'per_km_flat_rate_fee' => $this->per_km_flat_rate_fee,
85
- 'meter_fees' => ServiceRateFee::collection($this->rateFees ?? []),
86
- 'parcel_fees' => ServiceRateParcelFee::collection($this->rateFees ?? []),
85
+ 'rate_fees' => ServiceRateFee::collection($this->rateFees ?? []),
86
+ 'parcel_fees' => ServiceRateParcelFee::collection($this->parcelFees ?? []),
87
87
  'algorithm' => $this->algorithm,
88
88
  'has_cod_fee' => Utils::castBoolean($this->has_cod_fee),
89
89
  'cod_calculation_method' => $this->cod_calculation_method,
@@ -17,18 +17,18 @@ class ServiceRateFee extends FleetbaseResource
17
17
  public function toArray($request)
18
18
  {
19
19
  return [
20
- 'id' => $this->when(Http::isInternalRequest(), $this->id),
21
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
- 'fee' => $this->fee,
23
- 'currency' => $this->currency,
24
- 'size' => $this->size,
25
- 'length' => $this->length,
26
- 'height' => $this->height,
27
- 'dimensions_unit' => $this->dimensions_unit,
28
- 'weight' => $this->weight,
29
- 'weight_unit' => $this->weight_unit,
30
- 'updated_at' => $this->updated_at,
31
- 'created_at' => $this->created_at,
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'service_rate_uuid' => $this->when(Http::isInternalRequest(), $this->service_rate_uuid),
23
+ 'fee' => $this->fee,
24
+ 'currency' => $this->currency,
25
+ 'min' => $this->min,
26
+ 'max' => $this->max,
27
+ 'unit' => $this->unit,
28
+ 'distance' => $this->distance,
29
+ 'distance_unit' => $this->distance_unit,
30
+ 'updated_at' => $this->updated_at,
31
+ 'created_at' => $this->created_at,
32
32
  ];
33
33
  }
34
34
 
@@ -17,13 +17,20 @@ class ServiceRateParcelFee extends FleetbaseResource
17
17
  public function toArray($request)
18
18
  {
19
19
  return [
20
- 'id' => $this->when(Http::isInternalRequest(), $this->id),
21
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
- 'fee' => $this->fee,
23
- 'currency' => $this->currency,
24
- 'distance' => $this->distance,
25
- 'updated_at' => $this->updated_at,
26
- 'created_at' => $this->created_at,
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'service_rate_uuid' => $this->when(Http::isInternalRequest(), $this->service_rate_uuid),
23
+ 'fee' => $this->fee,
24
+ 'currency' => $this->currency,
25
+ 'size' => $this->size,
26
+ 'length' => $this->length,
27
+ 'width' => $this->width,
28
+ 'height' => $this->height,
29
+ 'dimensions_unit' => $this->dimensions_unit,
30
+ 'weight' => $this->weight,
31
+ 'weight_unit' => $this->weight_unit,
32
+ 'updated_at' => $this->updated_at,
33
+ 'created_at' => $this->created_at,
27
34
  ];
28
35
  }
29
36
 
@@ -23,7 +23,7 @@ class TrackingNumber extends FleetbaseResource
23
23
  'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
24
24
  'status_uuid' => $this->when(Http::isInternalRequest(), $this->status_uuid),
25
25
  'owner_uuid' => $this->when(Http::isInternalRequest(), $this->owner_uuid),
26
- 'owner_type' => $this->when(Http::isInternalRequest(), $this->owner_type),
26
+ 'owner_type' => $this->when(Http::isInternalRequest(), $this->owner_type ? Utils::toEmberResourceType($this->owner_type) : null),
27
27
  'tracking_number' => $this->tracking_number,
28
28
  'subject' => Utils::get($this->owner, 'public_id'),
29
29
  'region' => $this->region,
@@ -33,7 +33,7 @@ class Waypoint extends FleetbaseResource
33
33
  'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
34
34
  'waypoint_public_id' => $this->when(Http::isInternalRequest(), $waypoint->public_id),
35
35
  'customer_uuid' => $this->when(Http::isInternalRequest(), $waypoint->customer_uuid),
36
- 'customer_type' => $this->when(Http::isInternalRequest(), $waypoint->customer_type),
36
+ 'customer_type' => $this->when(Http::isInternalRequest(), $waypoint->customer_type ? Utils::toEmberResourceType($waypoint->customer_type) : null),
37
37
  'order' => $waypoint->order,
38
38
  'tracking' => $waypoint->tracking,
39
39
  'status' => $waypoint->status,
@@ -79,6 +79,11 @@ class HandleOrderDispatched implements ShouldQueue
79
79
  });
80
80
  })
81
81
  ->whereNull('deleted_at')
82
+ ->whereNotNull('location')->whereRaw('
83
+ ST_Y(location) BETWEEN -90 AND 90
84
+ AND ST_X(location) BETWEEN -180 AND 180
85
+ AND NOT (ST_X(location) = 0 AND ST_Y(location) = 0)
86
+ ')
82
87
  ->distanceSphere('location', $pickup, $distance)
83
88
  ->distanceSphereValue('location', $pickup)
84
89
  ->withoutGlobalScopes()
@@ -10,6 +10,7 @@ use Fleetbase\Models\Model;
10
10
  use Fleetbase\Models\User;
11
11
  use Fleetbase\Notifications\UserInvited;
12
12
  use Fleetbase\Traits\HasApiModelBehavior;
13
+ use Fleetbase\Traits\HasApiModelCache;
13
14
  use Fleetbase\Traits\HasCustomFields;
14
15
  use Fleetbase\Traits\HasInternalId;
15
16
  use Fleetbase\Traits\HasMetaAttributes;
@@ -34,6 +35,7 @@ class Contact extends Model
34
35
  use HasUuid;
35
36
  use HasPublicId;
36
37
  use HasApiModelBehavior;
38
+ use HasApiModelCache;
37
39
  use HasMetaAttributes;
38
40
  use HasInternalId;
39
41
  use TracksApiCredential;
@@ -11,6 +11,7 @@ use Fleetbase\Models\File;
11
11
  use Fleetbase\Models\Model;
12
12
  use Fleetbase\Models\User;
13
13
  use Fleetbase\Traits\HasApiModelBehavior;
14
+ use Fleetbase\Traits\HasApiModelCache;
14
15
  use Fleetbase\Traits\HasCustomFields;
15
16
  use Fleetbase\Traits\HasMetaAttributes;
16
17
  use Fleetbase\Traits\HasPublicId;
@@ -39,6 +40,7 @@ class Device extends Model
39
40
  use HasPublicId;
40
41
  use TracksApiCredential;
41
42
  use HasApiModelBehavior;
43
+ use HasApiModelCache;
42
44
  use HasSlug;
43
45
  use LogsActivity;
44
46
  use HasMetaAttributes;
@@ -8,6 +8,7 @@ use Fleetbase\Models\Company;
8
8
  use Fleetbase\Models\Model;
9
9
  use Fleetbase\Models\User;
10
10
  use Fleetbase\Traits\HasApiModelBehavior;
11
+ use Fleetbase\Traits\HasApiModelCache;
11
12
  use Fleetbase\Traits\HasMetaAttributes;
12
13
  use Fleetbase\Traits\HasPublicId;
13
14
  use Fleetbase\Traits\HasUuid;
@@ -30,6 +31,7 @@ class DeviceEvent extends Model
30
31
  use HasPublicId;
31
32
  use TracksApiCredential;
32
33
  use HasApiModelBehavior;
34
+ use HasApiModelCache;
33
35
  use LogsActivity;
34
36
  use HasMetaAttributes;
35
37
  use Searchable;
@@ -13,6 +13,7 @@ use Fleetbase\Models\File;
13
13
  use Fleetbase\Models\Model;
14
14
  use Fleetbase\Models\User;
15
15
  use Fleetbase\Traits\HasApiModelBehavior;
16
+ use Fleetbase\Traits\HasApiModelCache;
16
17
  use Fleetbase\Traits\HasCustomFields;
17
18
  use Fleetbase\Traits\HasInternalId;
18
19
  use Fleetbase\Traits\HasPublicId;
@@ -43,6 +44,7 @@ class Driver extends Model
43
44
  use HasInternalId;
44
45
  use TracksApiCredential;
45
46
  use HasApiModelBehavior;
47
+ use HasApiModelCache;
46
48
  use Notifiable;
47
49
  use SendsWebhooks;
48
50
  use SpatialTrait;
@@ -9,6 +9,7 @@ use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait;
9
9
  use Fleetbase\Models\Model;
10
10
  use Fleetbase\Models\User;
11
11
  use Fleetbase\Traits\HasApiModelBehavior;
12
+ use Fleetbase\Traits\HasApiModelCache;
12
13
  use Fleetbase\Traits\HasCustomFields;
13
14
  use Fleetbase\Traits\HasPublicId;
14
15
  use Fleetbase\Traits\HasUuid;
@@ -21,6 +22,7 @@ class FuelReport extends Model
21
22
  use TracksApiCredential;
22
23
  use HasPublicId;
23
24
  use HasApiModelBehavior;
25
+ use HasApiModelCache;
24
26
  use SpatialTrait;
25
27
  use Searchable;
26
28
  use HasCustomFields;