@fleetbase/fleetops-engine 0.3.3 → 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 (110) hide show
  1. package/addon/components/contact-form-panel.hbs +28 -6
  2. package/addon/components/driver-form-panel.hbs +10 -0
  3. package/addon/components/driver-form-panel.js +51 -0
  4. package/addon/components/driver-panel/details.hbs +1 -5
  5. package/addon/components/driver-panel.hbs +21 -3
  6. package/addon/components/fleet-form-panel.hbs +60 -6
  7. package/addon/components/fleet-panel/details.hbs +1 -1
  8. package/addon/components/fuel-report-form-panel.hbs +84 -8
  9. package/addon/components/fuel-report-form-panel.js +6 -0
  10. package/addon/components/fuel-report-panel/details.hbs +4 -0
  11. package/addon/components/issue-form-panel.hbs +99 -11
  12. package/addon/components/issue-form-panel.js +5 -13
  13. package/addon/components/layout/fleet-ops-sidebar.js +8 -0
  14. package/addon/components/live-map-drawer.hbs +1 -1
  15. package/addon/components/live-map.hbs +1 -1
  16. package/addon/components/modals/driver-assign-vehicle.hbs +2 -11
  17. package/addon/components/modals/driver-assign-vendor.hbs +1 -9
  18. package/addon/components/modals/fuel-report-details.hbs +4 -0
  19. package/addon/components/order/schedule-card.hbs +32 -4
  20. package/addon/components/order/schedule-card.js +155 -5
  21. package/addon/components/place-form-panel.hbs +14 -7
  22. package/addon/components/place-form-panel.js +71 -0
  23. package/addon/components/place-panel/details.hbs +9 -19
  24. package/addon/components/vehicle-form-panel.hbs +67 -7
  25. package/addon/components/vehicle-form-panel.js +37 -0
  26. package/addon/components/vehicle-panel/details.hbs +9 -5
  27. package/addon/components/vehicle-panel.hbs +18 -4
  28. package/addon/components/vendor-form-panel/create-form.hbs +72 -11
  29. package/addon/components/vendor-form-panel/edit-form.hbs +1 -1
  30. package/addon/components/vendor-form-panel.hbs +70 -30
  31. package/addon/components/vendor-form-panel.js +4 -40
  32. package/addon/components/vendor-panel/details.hbs +2 -2
  33. package/addon/components/vendor-panel.hbs +16 -2
  34. package/addon/controllers/management/contacts/index.js +42 -3
  35. package/addon/controllers/management/fleets/index.js +12 -23
  36. package/addon/controllers/management/fuel-reports/index/new.js +1 -1
  37. package/addon/controllers/management/fuel-reports/index.js +73 -20
  38. package/addon/controllers/management/issues/index/new.js +2 -2
  39. package/addon/controllers/management/issues/index.js +65 -45
  40. package/addon/controllers/management/places/index.js +59 -18
  41. package/addon/controllers/management/vehicles/index.js +67 -8
  42. package/addon/controllers/management/vendors/index.js +63 -8
  43. package/addon/controllers/operations/orders/index.js +42 -1
  44. package/addon/routes/management/contacts/index.js +8 -0
  45. package/addon/routes/management/fleets/index.js +8 -2
  46. package/addon/routes/management/fuel-reports/index.js +6 -0
  47. package/addon/routes/management/issues/index.js +9 -1
  48. package/addon/routes/management/places/index.js +11 -1
  49. package/addon/routes/management/vehicles/index.js +3 -3
  50. package/addon/routes/management/vendors/index.js +8 -0
  51. package/addon/routes/operations/scheduler/index.js +1 -1
  52. package/addon/templates/operations/orders/index.hbs +1 -1
  53. package/addon/utils/get-issue-categories.js +30 -0
  54. package/addon/utils/get-issue-types.js +3 -0
  55. package/addon/utils/get-vendor-status-options.js +3 -0
  56. package/addon/utils/get-vendor-type-options.js +41 -0
  57. package/app/utils/get-issue-categories.js +1 -0
  58. package/app/utils/get-issue-types.js +1 -0
  59. package/app/utils/get-vendor-categories.js +1 -0
  60. package/app/utils/get-vendor-status-options.js +1 -0
  61. package/app/utils/get-vendor-type-options.js +1 -0
  62. package/app/utils/get-vendor-types.js +1 -0
  63. package/composer.json +1 -1
  64. package/extension.json +1 -1
  65. package/package.json +4 -4
  66. package/server/migrations/2023_11_09_041807_add_status_column_to_fuel_reports_table.php +32 -0
  67. package/server/migrations/2023_11_15_062814_add_comments_column_and_resolved_at_column_to_vehicle_device_events_table.php +33 -0
  68. package/server/src/Http/Controllers/Api/v1/DriverController.php +2 -2
  69. package/server/src/Http/Controllers/Api/v1/VehicleController.php +2 -2
  70. package/server/src/Http/Controllers/Internal/v1/DriverController.php +5 -13
  71. package/server/src/Http/Controllers/Internal/v1/OrderController.php +1 -3
  72. package/server/src/Http/Filter/ContactFilter.php +10 -0
  73. package/server/src/Http/Filter/FleetFilter.php +8 -6
  74. package/server/src/Http/Filter/FuelReportFilter.php +51 -0
  75. package/server/src/Http/Filter/IssueFilter.php +61 -5
  76. package/server/src/Http/Filter/PlaceFilter.php +48 -6
  77. package/server/src/Http/Filter/VehicleFilter.php +21 -6
  78. package/server/src/Http/Filter/VendorFilter.php +11 -8
  79. package/server/src/Http/Middleware/TransformLocationMiddleware.php +1 -1
  80. package/server/src/Http/Resources/Internal/v1/IntegratedVendorFacilitator.php +17 -18
  81. package/server/src/Http/Resources/v1/Contact.php +16 -19
  82. package/server/src/Http/Resources/v1/CurrentJob.php +13 -16
  83. package/server/src/Http/Resources/v1/Driver.php +59 -57
  84. package/server/src/Http/Resources/v1/Entity.php +30 -33
  85. package/server/src/Http/Resources/v1/FuelReport.php +16 -14
  86. package/server/src/Http/Resources/v1/Order.php +1 -1
  87. package/server/src/Http/Resources/v1/Payload.php +21 -24
  88. package/server/src/Http/Resources/v1/Place.php +27 -30
  89. package/server/src/Http/Resources/v1/Proof.php +13 -16
  90. package/server/src/Http/Resources/v1/PurchaseRate.php +14 -17
  91. package/server/src/Http/Resources/v1/ServiceArea.php +13 -16
  92. package/server/src/Http/Resources/v1/ServiceQuote.php +15 -18
  93. package/server/src/Http/Resources/v1/ServiceRate.php +33 -36
  94. package/server/src/Http/Resources/v1/ServiceRateFee.php +14 -17
  95. package/server/src/Http/Resources/v1/ServiceRateParcelFee.php +9 -12
  96. package/server/src/Http/Resources/v1/TrackingNumber.php +18 -21
  97. package/server/src/Http/Resources/v1/TrackingStatus.php +18 -21
  98. package/server/src/Http/Resources/v1/Vehicle.php +31 -34
  99. package/server/src/Http/Resources/v1/VehicleDevice.php +23 -25
  100. package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +38 -32
  101. package/server/src/Http/Resources/v1/Vendor.php +31 -26
  102. package/server/src/Http/Resources/v1/Zone.php +14 -17
  103. package/server/src/Models/Driver.php +7 -1
  104. package/server/src/Models/FuelReport.php +1 -0
  105. package/server/src/Models/IntegratedVendor.php +6 -1
  106. package/server/src/Models/Order.php +2 -2
  107. package/server/src/Models/Place.php +2 -2
  108. package/server/src/Models/VehicleDeviceEvent.php +1 -0
  109. package/server/src/Models/Vendor.php +1 -1
  110. package/server/src/Observers/DriverObserver.php +15 -0
@@ -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
  /**
@@ -18,36 +18,33 @@ class Place 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
- 'name' => $this->name,
28
- 'location' => $this->location ?? new Point(0, 0),
29
- 'address' => $this->address,
30
- 'address_html' => $this->when(Http::isInternalRequest(), $this->address_html),
31
- 'street1' => $this->street1 ?? null,
32
- 'street2' => $this->street2 ?? null,
33
- 'city' => $this->city ?? null,
34
- 'province' => $this->province ?? null,
35
- 'postal_code' => $this->postal_code ?? null,
36
- 'neighborhood' => $this->neighborhood ?? null,
37
- 'district' => $this->district ?? null,
38
- 'building' => $this->building ?? null,
39
- 'security_access_code' => $this->security_access_code ?? null,
40
- 'country' => $this->country ?? null,
41
- 'country_name' => $this->when(Http::isInternalRequest(), $this->country_name),
42
- 'phone' => $this->phone ?? null,
43
- 'owner' => $this->when(!Http::isInternalRequest(), Resolve::resourceForMorph($this->owner_type, $this->owner_uuid)),
44
- 'tracking_number' => $this->whenLoaded('trackingNumber', $this->trackingNumber),
45
- 'type' => $this->type ?? null,
46
- 'meta' => $this->meta ?? [],
47
- 'updated_at' => $this->updated_at,
48
- 'created_at' => $this->created_at,
49
- ]
50
- );
21
+ return [
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
+ 'name' => $this->name,
26
+ 'location' => $this->location ?? new Point(0, 0),
27
+ 'address' => $this->address,
28
+ 'address_html' => $this->when(Http::isInternalRequest(), $this->address_html),
29
+ 'street1' => $this->street1 ?? null,
30
+ 'street2' => $this->street2 ?? null,
31
+ 'city' => $this->city ?? null,
32
+ 'province' => $this->province ?? null,
33
+ 'postal_code' => $this->postal_code ?? null,
34
+ 'neighborhood' => $this->neighborhood ?? null,
35
+ 'district' => $this->district ?? null,
36
+ 'building' => $this->building ?? null,
37
+ 'security_access_code' => $this->security_access_code ?? null,
38
+ 'country' => $this->country ?? null,
39
+ 'country_name' => $this->when(Http::isInternalRequest(), $this->country_name),
40
+ 'phone' => $this->phone ?? null,
41
+ 'owner' => $this->when(!Http::isInternalRequest(), Resolve::resourceForMorph($this->owner_type, $this->owner_uuid)),
42
+ 'tracking_number' => $this->whenLoaded('trackingNumber', $this->trackingNumber),
43
+ 'type' => $this->type ?? null,
44
+ 'meta' => $this->meta ?? [],
45
+ 'updated_at' => $this->updated_at,
46
+ 'created_at' => $this->created_at,
47
+ ];
51
48
  }
52
49
 
53
50
  /**