@fleetbase/fleetops-engine 0.3.2 → 0.3.4

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 (137) hide show
  1. package/addon/components/admin/visibility-controls.js +1 -0
  2. package/addon/components/contact-form-panel.hbs +28 -6
  3. package/addon/components/driver-form-panel.hbs +10 -0
  4. package/addon/components/driver-form-panel.js +51 -0
  5. package/addon/components/driver-panel/details.hbs +1 -5
  6. package/addon/components/driver-panel.hbs +21 -3
  7. package/addon/components/fleet-form-panel.hbs +60 -6
  8. package/addon/components/fleet-panel/details.hbs +1 -1
  9. package/addon/components/fuel-report-form-panel.hbs +84 -8
  10. package/addon/components/fuel-report-form-panel.js +6 -0
  11. package/addon/components/fuel-report-panel/details.hbs +4 -0
  12. package/addon/components/issue-form-panel.hbs +99 -11
  13. package/addon/components/issue-form-panel.js +5 -13
  14. package/addon/components/layout/fleet-ops-sidebar.js +10 -1
  15. package/addon/components/live-map-drawer/driver-listing.hbs +6 -0
  16. package/addon/components/live-map-drawer/driver-listing.js +240 -0
  17. package/addon/components/live-map-drawer/place-listing.hbs +6 -0
  18. package/addon/components/live-map-drawer/place-listing.js +204 -0
  19. package/addon/components/live-map-drawer/vehicle-listing.hbs +6 -0
  20. package/addon/components/live-map-drawer/vehicle-listing.js +216 -0
  21. package/addon/components/live-map-drawer.hbs +17 -0
  22. package/addon/components/live-map-drawer.js +104 -0
  23. package/addon/components/live-map.hbs +5 -1
  24. package/addon/components/live-map.js +107 -15
  25. package/addon/components/map-container/toolbar.hbs +6 -0
  26. package/addon/components/modals/driver-assign-vehicle.hbs +2 -11
  27. package/addon/components/modals/driver-assign-vendor.hbs +1 -9
  28. package/addon/components/modals/fuel-report-details.hbs +4 -0
  29. package/addon/components/modals/order-event.hbs +1 -1
  30. package/addon/components/order/schedule-card.hbs +35 -7
  31. package/addon/components/order/schedule-card.js +163 -6
  32. package/addon/components/place-form-panel.hbs +14 -7
  33. package/addon/components/place-form-panel.js +71 -0
  34. package/addon/components/place-panel/details.hbs +11 -21
  35. package/addon/components/vehicle-form-panel.hbs +67 -7
  36. package/addon/components/vehicle-form-panel.js +37 -0
  37. package/addon/components/vehicle-panel/details.hbs +9 -5
  38. package/addon/components/vehicle-panel.hbs +18 -4
  39. package/addon/components/vendor-form-panel/create-form.hbs +72 -11
  40. package/addon/components/vendor-form-panel/edit-form.hbs +1 -1
  41. package/addon/components/vendor-form-panel.hbs +70 -30
  42. package/addon/components/vendor-form-panel.js +4 -40
  43. package/addon/components/vendor-panel/details.hbs +2 -2
  44. package/addon/components/vendor-panel.hbs +16 -2
  45. package/addon/controllers/management/contacts/index.js +42 -3
  46. package/addon/controllers/management/fleets/index.js +12 -23
  47. package/addon/controllers/management/fuel-reports/index/new.js +1 -1
  48. package/addon/controllers/management/fuel-reports/index.js +73 -20
  49. package/addon/controllers/management/issues/index/new.js +2 -2
  50. package/addon/controllers/management/issues/index.js +65 -45
  51. package/addon/controllers/management/places/index.js +59 -18
  52. package/addon/controllers/management/vehicles/index.js +67 -8
  53. package/addon/controllers/management/vendors/index.js +63 -8
  54. package/addon/controllers/operations/orders/index.js +70 -15
  55. package/addon/controllers/operations/scheduler/index.js +45 -30
  56. package/addon/routes/management/contacts/index.js +8 -0
  57. package/addon/routes/management/fleets/index.js +8 -2
  58. package/addon/routes/management/fuel-reports/index.js +6 -0
  59. package/addon/routes/management/issues/index.js +9 -1
  60. package/addon/routes/management/places/index.js +11 -1
  61. package/addon/routes/management/vehicles/index.js +3 -3
  62. package/addon/routes/management/vendors/index.js +8 -0
  63. package/addon/routes/operations/scheduler/index.js +26 -1
  64. package/addon/styles/fleetops-engine.css +28 -0
  65. package/addon/templates/operations/orders/index.hbs +2 -2
  66. package/addon/templates/operations/scheduler/index.hbs +33 -9
  67. package/addon/utils/create-full-calendar-event-from-order.js +8 -0
  68. package/addon/utils/get-issue-categories.js +30 -0
  69. package/addon/utils/get-issue-types.js +3 -0
  70. package/addon/utils/get-vendor-status-options.js +3 -0
  71. package/addon/utils/get-vendor-type-options.js +41 -0
  72. package/app/components/live-map-drawer/driver-listing.js +1 -0
  73. package/app/components/live-map-drawer/place-listing.js +1 -0
  74. package/app/components/live-map-drawer/vehicle-listing.js +1 -0
  75. package/app/components/live-map-drawer.js +1 -0
  76. package/app/utils/create-full-calendar-event-from-order.js +1 -0
  77. package/app/utils/get-issue-categories.js +1 -0
  78. package/app/utils/get-issue-types.js +1 -0
  79. package/app/utils/get-vendor-categories.js +1 -0
  80. package/app/utils/get-vendor-status-options.js +1 -0
  81. package/app/utils/get-vendor-type-options.js +1 -0
  82. package/app/utils/get-vendor-types.js +1 -0
  83. package/composer.json +1 -1
  84. package/extension.json +1 -1
  85. package/package.json +4 -4
  86. package/server/migrations/2023_11_09_041807_add_status_column_to_fuel_reports_table.php +32 -0
  87. package/server/migrations/2023_11_15_062814_add_comments_column_and_resolved_at_column_to_vehicle_device_events_table.php +33 -0
  88. package/server/src/Http/Controllers/Api/v1/DriverController.php +2 -2
  89. package/server/src/Http/Controllers/Api/v1/VehicleController.php +2 -2
  90. package/server/src/Http/Controllers/Internal/v1/DriverController.php +5 -13
  91. package/server/src/Http/Controllers/Internal/v1/OrderController.php +1 -3
  92. package/server/src/Http/Filter/ContactFilter.php +10 -0
  93. package/server/src/Http/Filter/FleetFilter.php +8 -6
  94. package/server/src/Http/Filter/FuelReportFilter.php +51 -0
  95. package/server/src/Http/Filter/IssueFilter.php +61 -5
  96. package/server/src/Http/Filter/PlaceFilter.php +48 -6
  97. package/server/src/Http/Filter/VehicleFilter.php +21 -6
  98. package/server/src/Http/Filter/VendorFilter.php +11 -8
  99. package/server/src/Http/Middleware/TransformLocationMiddleware.php +1 -1
  100. package/server/src/Http/Resources/Internal/v1/IntegratedVendorFacilitator.php +17 -18
  101. package/server/src/Http/Resources/v1/Contact.php +16 -19
  102. package/server/src/Http/Resources/v1/CurrentJob.php +13 -16
  103. package/server/src/Http/Resources/v1/Driver.php +59 -57
  104. package/server/src/Http/Resources/v1/Entity.php +30 -33
  105. package/server/src/Http/Resources/v1/FuelReport.php +16 -14
  106. package/server/src/Http/Resources/v1/Order.php +1 -1
  107. package/server/src/Http/Resources/v1/Payload.php +21 -24
  108. package/server/src/Http/Resources/v1/Place.php +27 -30
  109. package/server/src/Http/Resources/v1/Proof.php +13 -16
  110. package/server/src/Http/Resources/v1/PurchaseRate.php +14 -17
  111. package/server/src/Http/Resources/v1/ServiceArea.php +13 -16
  112. package/server/src/Http/Resources/v1/ServiceQuote.php +15 -18
  113. package/server/src/Http/Resources/v1/ServiceRate.php +33 -36
  114. package/server/src/Http/Resources/v1/ServiceRateFee.php +14 -17
  115. package/server/src/Http/Resources/v1/ServiceRateParcelFee.php +9 -12
  116. package/server/src/Http/Resources/v1/TrackingNumber.php +18 -21
  117. package/server/src/Http/Resources/v1/TrackingStatus.php +18 -21
  118. package/server/src/Http/Resources/v1/Vehicle.php +31 -34
  119. package/server/src/Http/Resources/v1/VehicleDevice.php +23 -25
  120. package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +38 -32
  121. package/server/src/Http/Resources/v1/Vendor.php +31 -26
  122. package/server/src/Http/Resources/v1/Zone.php +14 -17
  123. package/server/src/Models/Driver.php +7 -1
  124. package/server/src/Models/FuelReport.php +2 -1
  125. package/server/src/Models/IntegratedVendor.php +6 -1
  126. package/server/src/Models/Order.php +24 -2
  127. package/server/src/Models/Place.php +2 -2
  128. package/server/src/Models/VehicleDevice.php +1 -1
  129. package/server/src/Models/VehicleDeviceEvent.php +2 -1
  130. package/server/src/Models/Vendor.php +1 -1
  131. package/server/src/Observers/DriverObserver.php +15 -0
  132. package/server/src/Observers/FleetObserver.php +19 -0
  133. package/server/src/Providers/FleetOpsServiceProvider.php +1 -0
  134. package/addon/components/full-calendar/draggable.js +0 -1
  135. package/addon/components/full-calendar.js +0 -1
  136. package/app/components/full-calendar/draggable.js +0 -1
  137. package/app/components/full-calendar.js +0 -1
@@ -17,9 +17,9 @@ class VehicleFilter extends Filter
17
17
  $this->builder->search($query);
18
18
  }
19
19
 
20
- public function name(?string $name)
20
+ public function display_name(?string $display_name)
21
21
  {
22
- $this->builder->searchWhere(['year', 'model_make_display', 'make', 'model', 'trim', 'plate_number'], $name);
22
+ $this->builder->searchWhere(['year', 'make', 'model', 'plate_number'], $display_name);
23
23
  }
24
24
 
25
25
  public function vin(?string $vin)
@@ -37,14 +37,19 @@ class VehicleFilter extends Filter
37
37
  $this->builder->searchWhere('plate_number', $plateNumber);
38
38
  }
39
39
 
40
- public function vehicleMake(?string $make)
40
+ public function vehicleMake(?string $vehicleMake)
41
41
  {
42
- $this->builder->searchWhere('make', $make);
42
+ $this->builder->searchWhere('make', $vehicleMake);
43
43
  }
44
44
 
45
- public function vehicleModel(?string $model)
45
+ public function vehicleModel(?string $vehicle_model)
46
46
  {
47
- $this->builder->searchWhere('model', $model);
47
+ $this->builder->searchWhere('model', $vehicle_model);
48
+ }
49
+
50
+ public function vehicleYear(?string $vehicleYear)
51
+ {
52
+ $this->builder->searchWhere('year', $vehicleYear);
48
53
  }
49
54
 
50
55
  public function driver(?string $driverId)
@@ -57,6 +62,16 @@ class VehicleFilter extends Filter
57
62
  );
58
63
  }
59
64
 
65
+ public function vendor(?string $vendorId)
66
+ {
67
+ $this->builder->whereHas(
68
+ 'vendor',
69
+ function ($query) use ($vendorId) {
70
+ $query->where('uuid', $vendorId);
71
+ }
72
+ );
73
+ }
74
+
60
75
  public function driverUuid(?string $driverId)
61
76
  {
62
77
  $this->builder->whereHas(
@@ -14,14 +14,7 @@ class VendorFilter extends Filter
14
14
 
15
15
  public function query(?string $searchQuery)
16
16
  {
17
- $this->builder->where(function ($query) use ($searchQuery) {
18
- $query->orWhereHas(
19
- 'user',
20
- function ($query) use ($searchQuery) {
21
- $query->searchWhere(['name', 'email', 'phone', 'address'], $searchQuery);
22
- }
23
- );
24
- });
17
+ $this->builder->search($searchQuery);
25
18
  }
26
19
 
27
20
  public function internalId(?string $internalId)
@@ -49,6 +42,11 @@ class VendorFilter extends Filter
49
42
  $this->builder->searchWhere('email', $email);
50
43
  }
51
44
 
45
+ public function websiteUrl(?string $websiteUrl)
46
+ {
47
+ $this->builder->searchWhere('website_url', $websiteUrl);
48
+ }
49
+
52
50
  public function country(?string $country)
53
51
  {
54
52
  $this->builder->searchWhere('country', $country);
@@ -59,6 +57,11 @@ class VendorFilter extends Filter
59
57
  $this->builder->searchWhere('status', $status);
60
58
  }
61
59
 
60
+ public function address(?string $address)
61
+ {
62
+ $this->builder->searchWhere('place_uuid', $address);
63
+ }
64
+
62
65
  public function createdAt($createdAt)
63
66
  {
64
67
  $createdAt = Utils::dateRange($createdAt);
@@ -35,7 +35,7 @@ class TransformLocationMiddleware
35
35
  {
36
36
  foreach ($data as $key => $value) {
37
37
  if (is_array($value)) {
38
- // If the value is an array, recursively transform it
38
+ // If the value is a valid coordinates type, recursively transform it
39
39
  $data[$key] = $this->transformNestedLocation($value);
40
40
  } elseif ($key === 'location' && $value === null) {
41
41
  // Transform the 'location' property if it's null
@@ -3,6 +3,7 @@
3
3
  namespace Fleetbase\FleetOps\Http\Resources\Internal\v1;
4
4
 
5
5
  use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
6
7
 
7
8
  class IntegratedVendorFacilitator extends FleetbaseResource
8
9
  {
@@ -15,23 +16,21 @@ class IntegratedVendorFacilitator extends FleetbaseResource
15
16
  */
16
17
  public function toArray($request)
17
18
  {
18
- return array_merge(
19
- $this->getInternalIds(),
20
- [
21
- 'id' => $this->public_id,
22
- 'public_id' => $this->public_id,
23
- 'uuid' => $this->uuid,
24
- 'name' => $this->name,
25
- 'photo_url' => $this->photo_url,
26
- 'provider' => $this->provider,
27
- 'options' => $this->options,
28
- 'sandbox' => $this->sandbox,
29
- 'facilitator_type' => $this->type,
30
- 'type' => 'facilitator',
31
- 'status' => $this->status,
32
- 'updated_at' => $this->updated_at,
33
- 'created_at' => $this->created_at,
34
- ]
35
- );
19
+ return [
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'public_id' => $this->public_id,
23
+ 'uuid' => $this->uuid,
24
+ 'name' => $this->name,
25
+ 'photo_url' => $this->photo_url,
26
+ 'provider' => $this->provider,
27
+ 'options' => $this->options,
28
+ 'sandbox' => $this->sandbox,
29
+ 'facilitator_type' => $this->type,
30
+ 'type' => 'facilitator',
31
+ 'status' => $this->status,
32
+ 'updated_at' => $this->updated_at,
33
+ 'created_at' => $this->created_at,
34
+ ];
36
35
  }
37
36
  }
@@ -16,25 +16,22 @@ class Contact extends FleetbaseResource
16
16
  */
17
17
  public function toArray($request)
18
18
  {
19
- return array_merge(
20
- $this->getInternalIds(),
21
- [
22
- 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
- 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
- 'internal_id' => $this->internal_id,
26
- 'name' => $this->name,
27
- 'title' => $this->title ?? null,
28
- 'email' => $this->email ?? null,
29
- 'phone' => $this->phone ?? null,
30
- 'photo_url' => $this->photo_url ?? null,
31
- 'type' => $this->type ?? null,
32
- 'meta' => $this->meta ?? [],
33
- 'slug' => $this->slug ?? null,
34
- 'updated_at' => $this->updated_at,
35
- 'created_at' => $this->created_at,
36
- ]
37
- );
19
+ return [
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
23
+ 'internal_id' => $this->internal_id,
24
+ 'name' => $this->name,
25
+ 'title' => $this->title ?? null,
26
+ 'email' => $this->email ?? null,
27
+ 'phone' => $this->phone ?? null,
28
+ 'photo_url' => $this->photo_url ?? null,
29
+ 'type' => $this->type ?? null,
30
+ 'meta' => $this->meta ?? [],
31
+ 'slug' => $this->slug ?? null,
32
+ 'updated_at' => $this->updated_at,
33
+ 'created_at' => $this->created_at,
34
+ ];
38
35
  }
39
36
 
40
37
  /**
@@ -16,21 +16,18 @@ class CurrentJob extends FleetbaseResource
16
16
  */
17
17
  public function toArray($request)
18
18
  {
19
- return array_merge(
20
- $this->getInternalIds(),
21
- [
22
- 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
- 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
- 'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
26
- 'internal_id' => $this->internal_id,
27
- 'payload' => $this->when(Http::isInternalRequest(), new Payload($this->payload)),
28
- 'type' => $this->type,
29
- 'status' => $this->status,
30
- 'meta' => $this->meta ?? [],
31
- 'updated_at' => $this->updated_at,
32
- 'created_at' => $this->created_at,
33
- ]
34
- );
19
+ return [
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
23
+ 'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
24
+ 'internal_id' => $this->internal_id,
25
+ 'payload' => $this->when(Http::isInternalRequest(), new Payload($this->payload)),
26
+ 'type' => $this->type,
27
+ 'status' => $this->status,
28
+ 'meta' => $this->meta ?? [],
29
+ 'updated_at' => $this->updated_at,
30
+ 'created_at' => $this->created_at,
31
+ ];
35
32
  }
36
33
  }
@@ -18,42 +18,44 @@ class Driver extends FleetbaseResource
18
18
  */
19
19
  public function toArray($request)
20
20
  {
21
- return array_merge(
22
- $this->getInternalIds(),
23
- [
24
- 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
25
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
26
- 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
27
- 'internal_id' => $this->internal_id,
28
- 'name' => $this->name,
29
- 'email' => $this->email ?? null,
30
- 'phone' => $this->phone ?? null,
31
- 'drivers_license_number' => $this->drivers_license_number ?? null,
32
- 'photo_url' => $this->photo_url ?? null,
33
- 'vehicle_name' => $this->when(Http::isInternalRequest(), $this->vehicle_name),
34
- 'vehicle_avatar' => $this->when(Http::isInternalRequest(), $this->vehicle_avatar),
35
- 'vendor_name' => $this->when(Http::isInternalRequest(), $this->vendor_name),
36
- 'vehicle' => $this->whenLoaded('vehicle', new VehicleWithoutDriver($this->vehicle)),
37
- 'current_job' => $this->whenLoaded('currentJob', new CurrentJob($this->currentJob)),
38
- 'current_job_id' => $this->when(Http::isInternalRequest(), data_get($this, 'currentJob.public_id')),
39
- 'jobs' => $this->whenLoaded('jobs', CurrentJob::collection($this->jobs()->without(['driverAssigned'])->get())),
40
- 'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
41
- 'fleets' => $this->whenLoaded('fleets', Fleet::collection($this->fleets()->without('drivers')->get())),
42
- 'location' => data_get($this, 'location', new Point(0, 0)),
43
- 'heading' => (int) data_get($this, 'heading', 0),
44
- 'altitude' => (int) data_get($this, 'altitude', 0),
45
- 'speed' => (int) data_get($this, 'speed', 0),
46
- 'country' => data_get($this, 'country'),
47
- 'currency' => data_get($this, 'currency', Utils::getCurrenyFromCountryCode($this->country)),
48
- 'city' => data_get($this, 'city', Utils::getCapitalCityFromCountryCode($this->country)),
49
- 'online' => data_get($this, 'online', false),
50
- 'status' => $this->status,
51
- 'token' => data_get($this, 'token'),
52
- 'meta' => $this->meta,
53
- 'updated_at' => $this->updated_at,
54
- 'created_at' => $this->created_at,
55
- ]
56
- );
21
+ return [
22
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
+ 'user_uuid' => $this->when(Http::isInternalRequest(), $this->user_uuid),
25
+ 'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
26
+ 'vehicle_uuid' => $this->when(Http::isInternalRequest(), $this->vehicle_uuid),
27
+ 'vendor_uuid' => $this->when(Http::isInternalRequest(), $this->vendor_uuid),
28
+ 'current_job_uuid' => $this->when(Http::isInternalRequest(), $this->current_job_uuid),
29
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
30
+ 'internal_id' => $this->internal_id,
31
+ 'name' => $this->name,
32
+ 'email' => $this->email ?? null,
33
+ 'phone' => $this->phone ?? null,
34
+ 'drivers_license_number' => $this->drivers_license_number ?? null,
35
+ 'photo_url' => $this->photo_url ?? null,
36
+ 'vehicle_name' => $this->when(Http::isInternalRequest(), $this->vehicle_name),
37
+ 'vehicle_avatar' => $this->when(Http::isInternalRequest(), $this->vehicle_avatar),
38
+ 'vendor_name' => $this->when(Http::isInternalRequest(), $this->vendor_name),
39
+ 'vehicle' => $this->whenLoaded('vehicle', new VehicleWithoutDriver($this->vehicle)),
40
+ 'current_job' => $this->whenLoaded('currentJob', new CurrentJob($this->currentJob)),
41
+ 'current_job_id' => $this->when(Http::isInternalRequest(), data_get($this, 'currentJob.public_id')),
42
+ 'jobs' => $this->whenLoaded('jobs', CurrentJob::collection($this->jobs()->without(['driverAssigned'])->get())),
43
+ 'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
44
+ 'fleets' => $this->whenLoaded('fleets', Fleet::collection($this->fleets()->without('drivers')->get())),
45
+ 'location' => data_get($this, 'location', new Point(0, 0)),
46
+ 'heading' => (int) data_get($this, 'heading', 0),
47
+ 'altitude' => (int) data_get($this, 'altitude', 0),
48
+ 'speed' => (int) data_get($this, 'speed', 0),
49
+ 'country' => data_get($this, 'country'),
50
+ 'currency' => data_get($this, 'currency', Utils::getCurrenyFromCountryCode($this->country)),
51
+ 'city' => data_get($this, 'city', Utils::getCapitalCityFromCountryCode($this->country)),
52
+ 'online' => data_get($this, 'online', false),
53
+ 'status' => $this->status,
54
+ 'token' => data_get($this, 'token'),
55
+ 'meta' => $this->meta,
56
+ 'updated_at' => $this->updated_at,
57
+ 'created_at' => $this->created_at,
58
+ ];
57
59
  }
58
60
 
59
61
  /**
@@ -64,27 +66,27 @@ class Driver extends FleetbaseResource
64
66
  public function toWebhookPayload()
65
67
  {
66
68
  return [
67
- 'id' => $this->public_id,
68
- 'internal_id' => $this->internal_id,
69
- 'name' => $this->name,
70
- 'email' => $this->email ?? null,
71
- 'phone' => $this->phone ?? null,
72
- 'photo_url' => $this->photo_url ?? null,
73
- 'vehicle' => $this->vehicle->public_id ?? null,
74
- 'current_job' => $this->currentJob->public_id ?? null,
75
- 'vendor' => $this->vendor->public_id ?? null,
76
- 'location' => $this->location ?? new Point(0, 0),
77
- 'heading' => $this->heading ?? null,
78
- 'altitude' => $this->altitude ?? null,
79
- 'speed' => $this->speed ?? null,
80
- 'country' => $this->country ?? null,
81
- 'currency' => $this->currency ?? null,
82
- 'city' => $this->city ?? null,
83
- 'online' => $this->online ?? false,
84
- 'status' => $this->status,
85
- 'meta' => $this->meta,
86
- 'updated_at' => $this->updated_at,
87
- 'created_at' => $this->created_at,
69
+ 'id' => $this->public_id,
70
+ 'internal_id' => $this->internal_id,
71
+ 'name' => $this->name,
72
+ 'email' => $this->email,
73
+ 'phone' => $this->phone,
74
+ 'photo_url' => $this->photo_url,
75
+ 'vehicle' => data_get($this, 'vehicle.public_id'),
76
+ 'current_job' => data_get($this, 'currentJob.public_id'),
77
+ 'vendor' => data_get($this, 'vendor.public_id'),
78
+ 'location' => data_get($this, 'location', new Point(0, 0)),
79
+ 'heading' => (int) data_get($this, 'heading', 0),
80
+ 'altitude' => (int) data_get($this, 'altitude', 0),
81
+ 'speed' => (int) data_get($this, 'speed', 0),
82
+ 'country' => data_get($this, 'country'),
83
+ 'currency' => data_get($this, 'currency', Utils::getCurrenyFromCountryCode($this->country)),
84
+ 'city' => data_get($this, 'city', Utils::getCapitalCityFromCountryCode($this->country)),
85
+ 'online' => data_get($this, 'online', false),
86
+ 'status' => $this->status,
87
+ 'meta' => $this->meta,
88
+ 'updated_at' => $this->updated_at,
89
+ 'created_at' => $this->created_at,
88
90
  ];
89
91
  }
90
92
  }
@@ -17,39 +17,36 @@ class Entity extends FleetbaseResource
17
17
  */
18
18
  public function toArray($request)
19
19
  {
20
- return array_merge(
21
- $this->getInternalIds(),
22
- [
23
- 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
24
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
25
- 'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
26
- 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
27
- 'customer_uuid' => $this->when(Http::isInternalRequest(), $this->customer_uuid),
28
- 'customer_type' => $this->when(Http::isInternalRequest(), $this->customer_type),
29
- 'internal_id' => $this->internal_id,
30
- 'name' => $this->name,
31
- 'type' => $this->type ?? null,
32
- 'destination' => $this->when(Http::isPublicRequest(), data_get($this, 'destination.public_id'), null),
33
- 'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
34
- 'tracking_number' => new TrackingNumber($this->trackingNumber),
35
- 'description' => $this->description ?? null,
36
- 'photo_url' => $this->photo_url ?? null,
37
- 'length' => $this->length ?? null,
38
- 'width' => $this->width ?? null,
39
- 'height' => $this->height ?? null,
40
- 'dimensions_unit' => $this->dimensions_unit ?? null,
41
- 'weight' => $this->weight ?? null,
42
- 'weight_unit' => $this->weight_unit ?? null,
43
- 'declared_value' => $this->declared_value ?? null,
44
- 'price' => $this->price ?? null,
45
- 'sale_price' => $this->sale_price ?? null,
46
- 'sku' => $this->sku ?? null,
47
- 'currency' => $this->currency ?? null,
48
- 'meta' => $this->meta ?? [],
49
- 'updated_at' => $this->updated_at,
50
- 'created_at' => $this->created_at,
51
- ]
52
- );
20
+ return [
21
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
22
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
23
+ 'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
24
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
+ 'customer_uuid' => $this->when(Http::isInternalRequest(), $this->customer_uuid),
26
+ 'customer_type' => $this->when(Http::isInternalRequest(), $this->customer_type),
27
+ 'internal_id' => $this->internal_id,
28
+ 'name' => $this->name,
29
+ 'type' => $this->type ?? null,
30
+ 'destination' => $this->when(Http::isPublicRequest(), data_get($this, 'destination.public_id'), null),
31
+ 'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
32
+ 'tracking_number' => new TrackingNumber($this->trackingNumber),
33
+ 'description' => $this->description ?? null,
34
+ 'photo_url' => $this->photo_url ?? null,
35
+ 'length' => $this->length ?? null,
36
+ 'width' => $this->width ?? null,
37
+ 'height' => $this->height ?? null,
38
+ 'dimensions_unit' => $this->dimensions_unit ?? null,
39
+ 'weight' => $this->weight ?? null,
40
+ 'weight_unit' => $this->weight_unit ?? null,
41
+ 'declared_value' => $this->declared_value ?? null,
42
+ 'price' => $this->price ?? null,
43
+ 'sale_price' => $this->sale_price ?? null,
44
+ 'sku' => $this->sku ?? null,
45
+ 'currency' => $this->currency ?? null,
46
+ 'meta' => $this->meta ?? [],
47
+ 'updated_at' => $this->updated_at,
48
+ 'created_at' => $this->created_at,
49
+ ];
53
50
  }
54
51
 
55
52
  /**
@@ -36,6 +36,7 @@ class FuelReport extends FleetbaseResource
36
36
  'volume' => $this->volume,
37
37
  'metric_unit' => $this->metric_unit,
38
38
  'type' => $this->type,
39
+ 'status' => $this->status,
39
40
  'location' => $this->location ?? new Point(0, 0),
40
41
  'updated_at' => $this->updated_at,
41
42
  'created_at' => $this->created_at,
@@ -50,20 +51,21 @@ class FuelReport extends FleetbaseResource
50
51
  public function toWebhookPayload()
51
52
  {
52
53
  return [
53
- 'id' => $this->public_id,
54
- 'reporter' => data_get($this, 'reportedBy.public_id'),
55
- 'driver' => data_get($this, 'driver.public_id'),
56
- 'vehicle' => data_get($this, 'vehicle.public_id'),
57
- 'report' => $this->report,
58
- 'odometer' => $this->odometer,
59
- 'amount' => $this->amount,
60
- 'currency' => $this->currency,
61
- 'volume' => $this->volume,
62
- 'metric_unit' => $this->metric_unit,
63
- 'type' => $this->type,
64
- 'location' => $this->location ?? new Point(0, 0),
65
- 'updated_at' => $this->updated_at,
66
- 'created_at' => $this->created_at,
54
+ 'id' => $this->public_id,
55
+ 'reporter' => data_get($this, 'reportedBy.public_id'),
56
+ 'driver' => data_get($this, 'driver.public_id'),
57
+ 'vehicle' => data_get($this, 'vehicle.public_id'),
58
+ 'report_name' => $this->report,
59
+ 'odometer' => $this->odometer,
60
+ 'amount' => $this->amount,
61
+ 'currency' => $this->currency,
62
+ 'volume' => $this->volume,
63
+ 'metric_unit' => $this->metric_unit,
64
+ 'type' => $this->type,
65
+ 'status' => $this->status,
66
+ 'location' => $this->location ?? new Point(0, 0),
67
+ 'updated_at' => $this->updated_at,
68
+ 'created_at' => $this->created_at,
67
69
  ];
68
70
  }
69
71
  }
@@ -40,7 +40,7 @@ class Order extends FleetbaseResource
40
40
  'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
41
41
  'payload' => new Payload($this->payload),
42
42
  'facilitator' => $this->setFacilitatorType(Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid)),
43
- 'driver_assigned' => new Driver($this->driverAssigned()->without(['jobs', 'currentJob', 'driverAssigned'])->first()),
43
+ 'driver_assigned' => new Driver($this->driverAssigned()->without(['jobs', 'currentJob'])->first()),
44
44
  'tracking_number' => new TrackingNumber($this->trackingNumber),
45
45
  'tracking_statuses' => $this->whenLoaded('trackingStatuses', TrackingStatus::collection($this->trackingStatuses)),
46
46
  'purchase_rate' => new PurchaseRate($this->purchaseRate),
@@ -17,30 +17,27 @@ class Payload extends FleetbaseResource
17
17
  */
18
18
  public function toArray($request)
19
19
  {
20
- return array_merge(
21
- $this->getInternalIds(),
22
- [
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
- 'current_waypoint_uuid' => $this->when(Http::isInternalRequest(), $this->current_waypoint_uuid),
27
- 'pickup_uuid' => $this->when(Http::isInternalRequest(), $this->pickup_uuid),
28
- 'dropoff_uuid' => $this->when(Http::isInternalRequest(), $this->dropoff_uuid),
29
- 'return_uuid' => $this->when(Http::isInternalRequest(), $this->return_uuid),
30
- 'current_waypoint' => $this->when(!Http::isInternalRequest() && $this->currentWaypoint, data_get($this, 'currentWaypoint.public_id'), null),
31
- 'pickup' => new Place($this->pickup),
32
- 'dropoff' => new Place($this->dropoff),
33
- 'return' => new Place($this->return),
34
- 'waypoints' => $this->waypoints($this->waypoints),
35
- 'entities' => Entity::collection($this->entities ?? []),
36
- 'cod_amount' => $this->cod_amount ?? null,
37
- 'cod_currency' => $this->cod_currency ?? null,
38
- 'cod_payment_method' => $this->cod_payment_method ?? null,
39
- 'meta' => $this->meta ?? [],
40
- 'updated_at' => $this->updated_at,
41
- 'created_at' => $this->created_at,
42
- ]
43
- );
20
+ return [
21
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
22
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
23
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
24
+ 'current_waypoint_uuid' => $this->when(Http::isInternalRequest(), $this->current_waypoint_uuid),
25
+ 'pickup_uuid' => $this->when(Http::isInternalRequest(), $this->pickup_uuid),
26
+ 'dropoff_uuid' => $this->when(Http::isInternalRequest(), $this->dropoff_uuid),
27
+ 'return_uuid' => $this->when(Http::isInternalRequest(), $this->return_uuid),
28
+ 'current_waypoint' => $this->when(!Http::isInternalRequest() && $this->currentWaypoint, data_get($this, 'currentWaypoint.public_id'), null),
29
+ 'pickup' => new Place($this->pickup),
30
+ 'dropoff' => new Place($this->dropoff),
31
+ 'return' => new Place($this->return),
32
+ 'waypoints' => $this->waypoints($this->waypoints),
33
+ 'entities' => Entity::collection($this->entities ?? []),
34
+ 'cod_amount' => $this->cod_amount ?? null,
35
+ 'cod_currency' => $this->cod_currency ?? null,
36
+ 'cod_payment_method' => $this->cod_payment_method ?? null,
37
+ 'meta' => $this->meta ?? [],
38
+ 'updated_at' => $this->updated_at,
39
+ 'created_at' => $this->created_at,
40
+ ];
44
41
  }
45
42
 
46
43
  /**