@fleetbase/fleetops-engine 0.3.3 → 0.3.5

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 (154) 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-listing-panel.hbs +2 -2
  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/fleet-listing.hbs +1 -0
  15. package/addon/components/layout/fleet-ops-sidebar/fleet-listing.js +3 -0
  16. package/addon/components/layout/fleet-ops-sidebar.hbs +4 -4
  17. package/addon/components/layout/fleet-ops-sidebar.js +10 -0
  18. package/addon/components/live-map-drawer.hbs +1 -1
  19. package/addon/components/live-map.hbs +1 -1
  20. package/addon/components/modals/driver-assign-vehicle.hbs +2 -11
  21. package/addon/components/modals/driver-assign-vendor.hbs +1 -9
  22. package/addon/components/modals/fuel-report-details.hbs +4 -0
  23. package/addon/components/order/schedule-card.hbs +32 -4
  24. package/addon/components/order/schedule-card.js +155 -5
  25. package/addon/components/place-form-panel.hbs +14 -7
  26. package/addon/components/place-form-panel.js +71 -0
  27. package/addon/components/place-panel/details.hbs +9 -19
  28. package/addon/components/vehicle-form-panel.hbs +67 -7
  29. package/addon/components/vehicle-form-panel.js +37 -0
  30. package/addon/components/vehicle-panel/details.hbs +9 -5
  31. package/addon/components/vehicle-panel.hbs +18 -4
  32. package/addon/components/vendor-form-panel/create-form.hbs +72 -11
  33. package/addon/components/vendor-form-panel/edit-form.hbs +1 -1
  34. package/addon/components/vendor-form-panel.hbs +70 -30
  35. package/addon/components/vendor-form-panel.js +4 -40
  36. package/addon/components/vendor-panel/details.hbs +2 -2
  37. package/addon/components/vendor-panel.hbs +16 -2
  38. package/addon/controllers/management/contacts/index.js +49 -3
  39. package/addon/controllers/management/drivers/index.js +7 -0
  40. package/addon/controllers/management/fleets/index.js +19 -23
  41. package/addon/controllers/management/fuel-reports/index/new.js +1 -1
  42. package/addon/controllers/management/fuel-reports/index.js +80 -20
  43. package/addon/controllers/management/issues/index/new.js +2 -2
  44. package/addon/controllers/management/issues/index.js +72 -45
  45. package/addon/controllers/management/places/index.js +65 -18
  46. package/addon/controllers/management/vehicles/index.js +56 -4
  47. package/addon/controllers/management/vendors/index.js +70 -8
  48. package/addon/controllers/operations/orders/index.js +42 -1
  49. package/addon/controllers/operations/service-rates/index.js +7 -0
  50. package/addon/routes/management/contacts/index.js +8 -0
  51. package/addon/routes/management/fleets/index.js +8 -2
  52. package/addon/routes/management/fuel-reports/index.js +6 -0
  53. package/addon/routes/management/issues/index.js +9 -1
  54. package/addon/routes/management/places/index.js +11 -1
  55. package/addon/routes/management/vehicles/index.js +1 -1
  56. package/addon/routes/management/vendors/index.js +8 -0
  57. package/addon/routes/operations/scheduler/index.js +1 -1
  58. package/addon/templates/management/contacts/index.hbs +1 -0
  59. package/addon/templates/management/drivers/index.hbs +2 -1
  60. package/addon/templates/management/fleets/index.hbs +23 -3
  61. package/addon/templates/management/fuel-reports/index.hbs +1 -0
  62. package/addon/templates/management/issues/index.hbs +22 -2
  63. package/addon/templates/management/places/index.hbs +9 -1
  64. package/addon/templates/management/vehicles/index.hbs +22 -2
  65. package/addon/templates/management/vendors/index.hbs +22 -2
  66. package/addon/templates/operations/orders/index.hbs +1 -1
  67. package/addon/templates/operations/service-rates/index.hbs +11 -3
  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/layout/fleet-ops-sidebar/fleet-listing.js +1 -0
  73. package/app/utils/get-issue-categories.js +1 -0
  74. package/app/utils/get-issue-types.js +1 -0
  75. package/app/utils/get-vendor-categories.js +1 -0
  76. package/app/utils/get-vendor-status-options.js +1 -0
  77. package/app/utils/get-vendor-type-options.js +1 -0
  78. package/app/utils/get-vendor-types.js +1 -0
  79. package/composer.json +1 -1
  80. package/extension.json +1 -1
  81. package/package.json +4 -4
  82. package/server/migrations/2023_04_27_053456_create_contacts_table.php +2 -2
  83. package/server/migrations/2023_04_27_053456_create_drivers_table.php +5 -5
  84. package/server/migrations/2023_04_27_053456_create_entities_table.php +5 -5
  85. package/server/migrations/2023_04_27_053456_create_fleet_drivers_table.php +2 -2
  86. package/server/migrations/2023_04_27_053456_create_fleets_table.php +3 -3
  87. package/server/migrations/2023_04_27_053456_create_fuel_reports_table.php +3 -3
  88. package/server/migrations/2023_04_27_053456_create_issues_table.php +4 -4
  89. package/server/migrations/2023_04_27_053456_create_orders_table.php +8 -8
  90. package/server/migrations/2023_04_27_053456_create_payloads_table.php +5 -5
  91. package/server/migrations/2023_04_27_053456_create_places_table.php +1 -1
  92. package/server/migrations/2023_04_27_053456_create_purchase_rates_table.php +4 -4
  93. package/server/migrations/2023_04_27_053456_create_service_areas_table.php +2 -2
  94. package/server/migrations/2023_04_27_053456_create_service_quote_items_table.php +1 -1
  95. package/server/migrations/2023_04_27_053456_create_service_quotes_table.php +3 -3
  96. package/server/migrations/2023_04_27_053456_create_service_rate_fees_table.php +1 -1
  97. package/server/migrations/2023_04_27_053456_create_service_rate_parcel_fees_table.php +1 -1
  98. package/server/migrations/2023_04_27_053456_create_service_rates_table.php +3 -3
  99. package/server/migrations/2023_04_27_053456_create_tracking_numbers_table.php +3 -3
  100. package/server/migrations/2023_04_27_053456_create_tracking_statuses_table.php +2 -2
  101. package/server/migrations/2023_04_27_053456_create_vehicles_table.php +3 -3
  102. package/server/migrations/2023_04_27_053456_create_vendors_table.php +5 -5
  103. package/server/migrations/2023_04_27_053456_create_waypoints_table.php +4 -4
  104. package/server/migrations/2023_04_27_053456_create_zones_table.php +2 -2
  105. package/server/migrations/2023_11_09_041807_add_status_column_to_fuel_reports_table.php +32 -0
  106. package/server/migrations/2023_11_15_062814_add_comments_column_and_resolved_at_column_to_vehicle_device_events_table.php +33 -0
  107. package/server/migrations/2023_11_17_053001_add_category_uuid_to_entities_table.php +33 -0
  108. package/server/src/Http/Controllers/Api/v1/DriverController.php +2 -2
  109. package/server/src/Http/Controllers/Api/v1/EntityController.php +2 -0
  110. package/server/src/Http/Controllers/Api/v1/VehicleController.php +2 -2
  111. package/server/src/Http/Controllers/Internal/v1/DriverController.php +5 -14
  112. package/server/src/Http/Controllers/Internal/v1/OrderController.php +1 -3
  113. package/server/src/Http/Filter/ContactFilter.php +10 -0
  114. package/server/src/Http/Filter/FleetFilter.php +8 -6
  115. package/server/src/Http/Filter/FuelReportFilter.php +51 -0
  116. package/server/src/Http/Filter/IssueFilter.php +61 -5
  117. package/server/src/Http/Filter/PlaceFilter.php +48 -6
  118. package/server/src/Http/Filter/VehicleFilter.php +21 -6
  119. package/server/src/Http/Filter/VendorFilter.php +11 -8
  120. package/server/src/Http/Middleware/TransformLocationMiddleware.php +1 -1
  121. package/server/src/Http/Resources/Internal/v1/IntegratedVendorFacilitator.php +17 -18
  122. package/server/src/Http/Resources/v1/Contact.php +16 -19
  123. package/server/src/Http/Resources/v1/CurrentJob.php +13 -16
  124. package/server/src/Http/Resources/v1/Driver.php +59 -57
  125. package/server/src/Http/Resources/v1/Entity.php +30 -33
  126. package/server/src/Http/Resources/v1/Fleet.php +19 -17
  127. package/server/src/Http/Resources/v1/FuelReport.php +16 -14
  128. package/server/src/Http/Resources/v1/Order.php +1 -1
  129. package/server/src/Http/Resources/v1/Payload.php +21 -24
  130. package/server/src/Http/Resources/v1/Place.php +27 -30
  131. package/server/src/Http/Resources/v1/Proof.php +13 -16
  132. package/server/src/Http/Resources/v1/PurchaseRate.php +14 -17
  133. package/server/src/Http/Resources/v1/ServiceArea.php +13 -16
  134. package/server/src/Http/Resources/v1/ServiceQuote.php +15 -18
  135. package/server/src/Http/Resources/v1/ServiceRate.php +33 -36
  136. package/server/src/Http/Resources/v1/ServiceRateFee.php +14 -17
  137. package/server/src/Http/Resources/v1/ServiceRateParcelFee.php +9 -12
  138. package/server/src/Http/Resources/v1/TrackingNumber.php +18 -21
  139. package/server/src/Http/Resources/v1/TrackingStatus.php +18 -21
  140. package/server/src/Http/Resources/v1/Vehicle.php +31 -34
  141. package/server/src/Http/Resources/v1/VehicleDevice.php +23 -25
  142. package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +38 -32
  143. package/server/src/Http/Resources/v1/Vendor.php +31 -26
  144. package/server/src/Http/Resources/v1/Zone.php +14 -17
  145. package/server/src/Models/Driver.php +23 -1
  146. package/server/src/Models/Entity.php +18 -23
  147. package/server/src/Models/FuelReport.php +1 -0
  148. package/server/src/Models/IntegratedVendor.php +6 -1
  149. package/server/src/Models/Order.php +2 -2
  150. package/server/src/Models/Place.php +2 -2
  151. package/server/src/Models/Vehicle.php +4 -2
  152. package/server/src/Models/VehicleDeviceEvent.php +1 -0
  153. package/server/src/Models/Vendor.php +1 -1
  154. package/server/src/Observers/DriverObserver.php +15 -0
@@ -3,6 +3,7 @@
3
3
  namespace Fleetbase\FleetOps\Http\Resources\v1;
4
4
 
5
5
  use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
6
7
 
7
8
  class VehicleDevice extends FleetbaseResource
8
9
  {
@@ -15,30 +16,27 @@ class VehicleDevice extends FleetbaseResource
15
16
  */
16
17
  public function toArray($request)
17
18
  {
18
- return array_merge(
19
- $this->getInternalIds(),
20
- [
21
- 'id' => $this->id,
22
- 'uuid' => $this->uuid,
23
- 'vehicle_uuid' => $this->vehicle_uuid,
24
- 'device_id' => $this->device_id,
25
- 'device_provider' => $this->device_provider,
26
- 'device_type' => $this->device_type,
27
- 'device_name' => $this->device_name,
28
- 'device_model' => $this->device_model,
29
- 'device_location' => $this->device_location,
30
- 'manufacturer' => $this->manufacturer,
31
- 'serial_number' => $this->serial_number,
32
- 'installation_date' => $this->installation_date,
33
- 'last_maintenance_date' => $this->last_maintenance_date,
34
- 'meta' => $this->meta ?? [],
35
- 'data' => $this->data ?? [],
36
- 'status' => $this->status,
37
- 'data_frequency' => $this->data_frequency,
38
- 'notes' => $this->notes,
39
- 'updated_at' => $this->updated_at,
40
- 'created_at' => $this->created_at,
41
- ]
42
- );
19
+ return [
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'vehicle_uuid' => $this->vehicle_uuid,
23
+ 'device_id' => $this->device_id,
24
+ 'device_provider' => $this->device_provider,
25
+ 'device_type' => $this->device_type,
26
+ 'device_name' => $this->device_name,
27
+ 'device_model' => $this->device_model,
28
+ 'device_location' => $this->device_location,
29
+ 'manufacturer' => $this->manufacturer,
30
+ 'serial_number' => $this->serial_number,
31
+ 'installation_date' => $this->installation_date,
32
+ 'last_maintenance_date' => $this->last_maintenance_date,
33
+ 'meta' => $this->meta ?? [],
34
+ 'data' => $this->data ?? [],
35
+ 'status' => $this->status,
36
+ 'data_frequency' => $this->data_frequency,
37
+ 'notes' => $this->notes,
38
+ 'updated_at' => $this->updated_at,
39
+ 'created_at' => $this->created_at,
40
+ ];
43
41
  }
44
42
  }
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
4
 
5
5
  use Fleetbase\Http\Resources\FleetbaseResource;
6
6
  use Fleetbase\Support\Http;
7
+ use Grimzy\LaravelMysqlSpatial\Types\Point;
7
8
 
8
9
  class VehicleWithoutDriver extends FleetbaseResource
9
10
  {
@@ -16,30 +17,35 @@ class VehicleWithoutDriver extends FleetbaseResource
16
17
  */
17
18
  public function toArray($request)
18
19
  {
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
- 'vin' => $this->vin ?? null,
28
- 'photo' => $this->photoUrl ?? null,
29
- 'make' => $this->make ?? null,
30
- 'model' => $this->model ?? null,
31
- 'year' => $this->year ?? null,
32
- 'trim' => $this->trim ?? null,
33
- 'type' => $this->type ?? null,
34
- 'plate_number' => $this->plate_number ?? null,
35
- 'vin_data' => $this->vin_data,
36
- 'status' => $this->status,
37
- 'online' => $this->online,
38
- 'meta' => $this->meta,
39
- 'updated_at' => $this->updated_at,
40
- 'created_at' => $this->created_at,
41
- ]
42
- );
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
+ 'internal_id' => $this->internal_id,
25
+ 'name' => $this->display_name,
26
+ 'display_name' => $this->when(Http::isInternalRequest(), $this->display_name),
27
+ 'vin' => $this->vin ?? null,
28
+ 'devices' => $this->whenLoaded('devices', $this->devices),
29
+ 'photo_url' => $this->photo_url,
30
+ 'avatar_url' => $this->avatar_url,
31
+ 'make' => $this->make,
32
+ 'model' => $this->model,
33
+ 'year' => $this->year,
34
+ 'trim' => $this->trim,
35
+ 'type' => $this->type,
36
+ 'plate_number' => $this->plate_number,
37
+ 'vin' => $this->vin,
38
+ 'vin_data' => $this->vin_data,
39
+ 'status' => $this->status,
40
+ 'online' => $this->online,
41
+ 'location' => data_get($this, 'location', new Point(0, 0)),
42
+ 'heading' => (int) data_get($this, 'heading', 0),
43
+ 'altitude' => (int) data_get($this, 'altitude', 0),
44
+ 'speed' => (int) data_get($this, 'speed', 0),
45
+ 'meta' => data_get($this, 'meta', []),
46
+ 'updated_at' => $this->updated_at,
47
+ 'created_at' => $this->created_at,
48
+ ];
43
49
  }
44
50
 
45
51
  /**
@@ -53,14 +59,14 @@ class VehicleWithoutDriver extends FleetbaseResource
53
59
  'id' => $this->public_id,
54
60
  'internal_id' => $this->internal_id,
55
61
  'name' => $this->name,
56
- 'vin' => $this->vin ?? null,
57
- 'photo' => $this->photoUrl ?? null,
58
- 'make' => $this->make ?? null,
59
- 'model' => $this->model ?? null,
60
- 'year' => $this->year ?? null,
61
- 'trim' => $this->trim ?? null,
62
- 'type' => $this->type ?? null,
63
- 'plate_number' => $this->plate_number ?? null,
62
+ 'vin' => data_get($this, 'vin'),
63
+ 'photo' => data_get($this, 'photoUrl'),
64
+ 'make' => data_get($this, 'make'),
65
+ 'model' => data_get($this, 'model'),
66
+ 'year' => data_get($this, 'year'),
67
+ 'trim' => data_get($this, 'trim'),
68
+ 'type' => data_get($this, 'type'),
69
+ 'plate_number' => data_get($this, 'plate_number'),
64
70
  'vin_data' => $this->vin_data,
65
71
  'status' => $this->status,
66
72
  'online' => $this->online,
@@ -17,32 +17,33 @@ class Vendor 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
- 'place_uuid' => $this->when(Http::isInternalRequest(), $this->place_uuid),
27
- 'connect_company_uuid' => $this->when(Http::isInternalRequest(), $this->connect_company_uuid),
28
- 'logo_uuid' => $this->when(Http::isInternalRequest(), $this->logo_uuid),
29
- 'type_uuid' => $this->when(Http::isInternalRequest(), $this->type_uuid),
30
- 'internal_id' => $this->internal_id,
31
- 'business_id' => $this->business_id,
32
- 'name' => $this->name,
33
- 'email' => $this->email,
34
- 'phone' => $this->phone,
35
- 'photo_url' => Utils::or($this, ['logo_url', 'photo_url']),
36
- 'place' => $this->whenLoaded('place', new Place($this->place)),
37
- 'address' => $this->when(Http::isInternalRequest(), data_get($this, 'place.address')),
38
- 'address_street' => $this->when(Http::isInternalRequest(), data_get($this, 'place.street1')),
39
- 'type' => $this->type,
40
- 'meta' => $this->meta ?? [],
41
- 'slug' => $this->slug,
42
- 'updated_at' => $this->updated_at,
43
- 'created_at' => $this->created_at,
44
- ]
45
- );
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
+ 'place_uuid' => $this->when(Http::isInternalRequest(), $this->place_uuid),
25
+ 'connect_company_uuid' => $this->when(Http::isInternalRequest(), $this->connect_company_uuid),
26
+ 'logo_uuid' => $this->when(Http::isInternalRequest(), $this->logo_uuid),
27
+ 'type_uuid' => $this->when(Http::isInternalRequest(), $this->type_uuid),
28
+ 'internal_id' => $this->internal_id,
29
+ 'business_id' => $this->business_id,
30
+ 'name' => $this->name,
31
+ 'email' => $this->email,
32
+ 'phone' => $this->phone,
33
+ 'logo_url' => $this->logo_url,
34
+ 'photo_url' => Utils::or($this, ['logo_url', 'photo_url']),
35
+ 'place' => $this->whenLoaded('place', new Place($this->place)),
36
+ 'address' => $this->when(Http::isInternalRequest(), data_get($this, 'place.address')),
37
+ 'address_street' => $this->when(Http::isInternalRequest(), data_get($this, 'place.street1')),
38
+ 'country' => $this->country,
39
+ 'type' => $this->type,
40
+ 'meta' => $this->meta ?? [],
41
+ 'status' => $this->status,
42
+ 'slug' => $this->slug,
43
+ 'updated_at' => $this->updated_at,
44
+ 'created_at' => $this->created_at,
45
+ 'website_url' => $this->website_url,
46
+ ];
46
47
  }
47
48
 
48
49
  /**
@@ -58,15 +59,19 @@ class Vendor extends FleetbaseResource
58
59
  'name' => $this->name,
59
60
  'email' => $this->email,
60
61
  'phone' => $this->phone,
62
+ 'logo_url' => $this->logo_url,
61
63
  'photo_url' => Utils::or($this, ['logo_url', 'photo_url']),
62
64
  'place' => $this->whenLoaded('place', new Place($this->place)),
63
65
  'address' => data_get($this, 'place.address'),
64
66
  'address_street' => data_get($this, 'place.street1'),
67
+ 'country' => $this->country,
65
68
  'type' => $this->type,
66
69
  'meta' => $this->meta ?? [],
70
+ 'status' => $this->status,
67
71
  'slug' => $this->slug,
68
72
  'updated_at' => $this->updated_at,
69
73
  'created_at' => $this->created_at,
74
+ 'website_url' => $this->website_url,
70
75
  ];
71
76
  }
72
77
  }
@@ -18,23 +18,20 @@ class Zone 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
- 'description' => $this->description,
29
- 'coordinates' => $this->when($this->border instanceof Polygon, Utils::getCoordinatesFromPolygon($this->border), []),
30
- 'border' => $this->border,
31
- 'color' => $this->color,
32
- 'stroke_color' => $this->stroke_color,
33
- 'status' => $this->status,
34
- 'updated_at' => $this->updated_at,
35
- 'created_at' => $this->created_at,
36
- ]
37
- );
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
+ 'description' => $this->description,
27
+ 'coordinates' => $this->when($this->border instanceof Polygon, Utils::getCoordinatesFromPolygon($this->border), []),
28
+ 'border' => $this->border,
29
+ 'color' => $this->color,
30
+ 'stroke_color' => $this->stroke_color,
31
+ 'status' => $this->status,
32
+ 'updated_at' => $this->updated_at,
33
+ 'created_at' => $this->created_at,
34
+ ];
38
35
  }
39
36
 
40
37
  /**
@@ -18,6 +18,7 @@ use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
18
18
  use Illuminate\Broadcasting\Channel;
19
19
  use Illuminate\Notifications\Notifiable;
20
20
  use Illuminate\Support\Facades\DB;
21
+ use Illuminate\Support\Str;
21
22
  use Spatie\Activitylog\Traits\CausesActivity;
22
23
  use Spatie\Activitylog\Traits\LogsActivity;
23
24
  use Spatie\Sluggable\HasSlug;
@@ -88,6 +89,13 @@ class Driver extends Model
88
89
  'status',
89
90
  ];
90
91
 
92
+ /**
93
+ * The attributes that are guarded and not mass assignable.
94
+ *
95
+ * @var array
96
+ */
97
+ protected $guarded = [];
98
+
91
99
  /**
92
100
  * The attributes that are spatial columns.
93
101
  *
@@ -101,7 +109,6 @@ class Driver extends Model
101
109
  * @var array
102
110
  */
103
111
  protected $casts = [
104
- 'meta' => Json::class,
105
112
  'location' => Point::class,
106
113
  'online' => 'boolean',
107
114
  ];
@@ -540,4 +547,19 @@ class Driver extends Model
540
547
 
541
548
  return $position;
542
549
  }
550
+
551
+ /**
552
+ * Get the user relationship from the driver.
553
+ */
554
+ public function getUser(): ?\Fleetbase\Models\User
555
+ {
556
+ // get user
557
+ $user = $this->load(['user'])->user;
558
+
559
+ if (empty($user) && Str::isUuid($this->user_uuid)) {
560
+ $user = \Fleetbase\Models\User::where('uuid', $this->user_uuid)->first();
561
+ }
562
+
563
+ return $user;
564
+ }
543
565
  }
@@ -68,6 +68,7 @@ class Entity extends Model
68
68
  'customer_type',
69
69
  'tracking_number_uuid',
70
70
  'destination_uuid',
71
+ 'supplier_uuid',
71
72
  'photo_uuid',
72
73
  '_import_id',
73
74
  'internal_id',
@@ -160,9 +161,7 @@ class Entity extends Model
160
161
  }
161
162
 
162
163
  /**
163
- * Photo of entity belongs to.
164
- *
165
- * @var Model
164
+ * @var \Illuminate\Database\Eloquent\Relations\BelongsTo
166
165
  */
167
166
  public function photo()
168
167
  {
@@ -170,9 +169,7 @@ class Entity extends Model
170
169
  }
171
170
 
172
171
  /**
173
- * Files assosciated with entity.
174
- *
175
- * @var Model
172
+ * @var \Illuminate\Database\Eloquent\Relations\HasMany
176
173
  */
177
174
  public function files()
178
175
  {
@@ -180,7 +177,7 @@ class Entity extends Model
180
177
  }
181
178
 
182
179
  /**
183
- * The proofs for this order.
180
+ * @var \Illuminate\Database\Eloquent\Relations\HasMany
184
181
  */
185
182
  public function proofs()
186
183
  {
@@ -188,9 +185,7 @@ class Entity extends Model
188
185
  }
189
186
 
190
187
  /**
191
- * The entity destination.
192
- *
193
- * @var Model
188
+ * @var \Illuminate\Database\Eloquent\Relations\BelongsTo
194
189
  */
195
190
  public function destination()
196
191
  {
@@ -198,9 +193,7 @@ class Entity extends Model
198
193
  }
199
194
 
200
195
  /**
201
- * Payload entity belongs to.
202
- *
203
- * @var Model
196
+ * @var \Illuminate\Database\Eloquent\Relations\BelongsTo
204
197
  */
205
198
  public function payload()
206
199
  {
@@ -208,9 +201,15 @@ class Entity extends Model
208
201
  }
209
202
 
210
203
  /**
211
- * Driver assigned to order.
212
- *
213
- * @var Model
204
+ * @var \Illuminate\Database\Eloquent\Relations\BelongsTo
205
+ */
206
+ public function supplier()
207
+ {
208
+ return $this->belongsTo(Vendor::class, 'supplier_uuid');
209
+ }
210
+
211
+ /**
212
+ * @var \Illuminate\Database\Eloquent\Relations\BelongsTo
214
213
  */
215
214
  public function driver()
216
215
  {
@@ -218,9 +217,7 @@ class Entity extends Model
218
217
  }
219
218
 
220
219
  /**
221
- * The company who manages this order.
222
- *
223
- * @var Model
220
+ * @var \Illuminate\Database\Eloquent\Relations\BelongsTo
224
221
  */
225
222
  public function company()
226
223
  {
@@ -228,7 +225,7 @@ class Entity extends Model
228
225
  }
229
226
 
230
227
  /**
231
- * The tracking number assosicated to the entity.
228
+ * @var \Illuminate\Database\Eloquent\Relations\BelongsTo
232
229
  */
233
230
  public function trackingNumber()
234
231
  {
@@ -236,9 +233,7 @@ class Entity extends Model
236
233
  }
237
234
 
238
235
  /**
239
- * The customer of this order.
240
- *
241
- * @var Model
236
+ * @var \Illuminate\Database\Eloquent\Relations\MorphTo
242
237
  */
243
238
  public function customer()
244
239
  {
@@ -61,6 +61,7 @@ class FuelReport extends Model
61
61
  'volume',
62
62
  'metric_unit',
63
63
  'meta',
64
+ 'status',
64
65
  ];
65
66
 
66
67
  /**
@@ -69,7 +69,7 @@ class IntegratedVendor extends Model
69
69
  *
70
70
  * @var array
71
71
  */
72
- protected $appends = ['name', 'status', 'type', 'photo_url', 'service_types', 'supported_countries', 'provider_settings'];
72
+ protected $appends = ['name', 'status', 'type', 'photo_url', 'logo_url', 'service_types', 'supported_countries', 'provider_settings'];
73
73
 
74
74
  /**
75
75
  * The attributes excluded from the model's JSON form.
@@ -207,6 +207,11 @@ class IntegratedVendor extends Model
207
207
  return $this->provider()->getLogo();
208
208
  }
209
209
 
210
+ public function getLogoUrlAttribute()
211
+ {
212
+ return $this->provider()->getLogo();
213
+ }
214
+
210
215
  public function getStatusAttribute()
211
216
  {
212
217
  return 'active';
@@ -312,7 +312,7 @@ class Order extends Model
312
312
  */
313
313
  public function driverAssigned()
314
314
  {
315
- return $this->belongsTo(Driver::class)->without(['devices', 'vehicle', 'vendor'])->withoutGlobalScopes();
315
+ return $this->belongsTo(Driver::class)->without(['devices', 'vendor']);
316
316
  }
317
317
 
318
318
  /**
@@ -320,7 +320,7 @@ class Order extends Model
320
320
  */
321
321
  public function driver()
322
322
  {
323
- return $this->belongsTo(Driver::class)->without(['devices', 'vehicle', 'vendor'])->withoutGlobalScopes();
323
+ return $this->belongsTo(Driver::class)->without(['devices', 'vendor']);
324
324
  }
325
325
 
326
326
  /**
@@ -213,7 +213,7 @@ class Place extends Model
213
213
  }
214
214
 
215
215
  if (empty($this->country) && $address) {
216
- $this->setAttribute('country', $address->getCountry()->getCode());
216
+ $this->setAttribute('country', $address->getCountry() instanceof \Geocoder\Model\Country ? $address->getCountry()->getCode() : null);
217
217
  }
218
218
 
219
219
  if ($coordinates = $address->getCoordinates()) {
@@ -243,7 +243,7 @@ class Place extends Model
243
243
  $attributes['neighborhood'] = $address->getNeighborhood();
244
244
  $attributes['city'] = $address->getLocality();
245
245
  $attributes['building'] = $address->getStreetNumber();
246
- $attributes['country'] = $address->getCountry()->getCode();
246
+ $attributes['country'] = $address->getCountry() instanceof \Geocoder\Model\Country ? $address->getCountry()->getCode() : null;
247
247
  $attributes['location'] = new \Grimzy\LaravelMysqlSpatial\Types\Point($coordinates->getLatitude(), $coordinates->getLongitude());
248
248
 
249
249
  return $attributes;
@@ -7,6 +7,7 @@ use Fleetbase\FleetOps\Casts\Point;
7
7
  use Fleetbase\FleetOps\Support\Utils;
8
8
  use Fleetbase\Models\Model;
9
9
  use Fleetbase\Traits\HasApiModelBehavior;
10
+ use Fleetbase\Traits\HasMetaAttributes;
10
11
  use Fleetbase\Traits\HasPublicId;
11
12
  use Fleetbase\Traits\HasUuid;
12
13
  use Fleetbase\Traits\Searchable;
@@ -27,6 +28,7 @@ class Vehicle extends Model
27
28
  use Searchable;
28
29
  use HasSlug;
29
30
  use LogsActivity;
31
+ use HasMetaAttributes;
30
32
 
31
33
  /**
32
34
  * The database table used by the model.
@@ -54,7 +56,7 @@ class Vehicle extends Model
54
56
  *
55
57
  * @var array
56
58
  */
57
- protected $filterParams = ['vendor', 'driver', 'driver_uuid'];
59
+ protected $filterParams = ['vendor', 'driver', 'driver_uuid', 'vehicle_make', 'vehicle_model'];
58
60
 
59
61
  /**
60
62
  * Relationships to auto load with driver.
@@ -165,7 +167,7 @@ class Vehicle extends Model
165
167
  'location' => Point::class,
166
168
  'meta' => Json::class,
167
169
  'telematics' => Json::class,
168
- 'model' => Json::class,
170
+ 'model_data' => Json::class,
169
171
  'vin_data' => Json::class,
170
172
  'online' => 'boolean',
171
173
  ];
@@ -44,6 +44,7 @@ class VehicleDeviceEvent extends Model
44
44
  'state',
45
45
  'code',
46
46
  'reason',
47
+ 'comment',
47
48
  ];
48
49
  /**
49
50
  * The attributes that should be cast to native types.
@@ -72,7 +72,7 @@ class Vendor extends Model
72
72
  *
73
73
  * @var array
74
74
  */
75
- protected $searchableColumns = ['name', 'email', 'business_id', 'company.name'];
75
+ protected $searchableColumns = ['name', 'email', 'business_id', 'connectCompany.name'];
76
76
 
77
77
  /**
78
78
  * Dynamic attributes that are appended to object.
@@ -3,6 +3,7 @@
3
3
  namespace Fleetbase\FleetOps\Observers;
4
4
 
5
5
  use Fleetbase\FleetOps\Models\Driver;
6
+ use Fleetbase\FleetOps\Models\Order;
6
7
  use Fleetbase\Models\User;
7
8
  use Grimzy\LaravelMysqlSpatial\Types\Point;
8
9
 
@@ -21,6 +22,17 @@ class DriverObserver
21
22
  }
22
23
  }
23
24
 
25
+ /**
26
+ * Handle the Driver "deleting" event.
27
+ *
28
+ * @return void
29
+ */
30
+ public function deleting(Driver $driver)
31
+ {
32
+ // unassign the vehicle from the driver
33
+ $driver->vehicle_uuid = null;
34
+ }
35
+
24
36
  /**
25
37
  * Handle the Driver "deleted" event.
26
38
  *
@@ -30,5 +42,8 @@ class DriverObserver
30
42
  {
31
43
  // if the driver is deleted, delete their user account assosciated as well
32
44
  User::where(['uuid' => $driver->user_uuid, 'type' => 'driver'])->delete();
45
+
46
+ // also unassign them from any order they are assigned to
47
+ Order::where(['driver_assigned_uui' => $driver->uuid])->update(['driver_assigned_uui' => null]);
33
48
  }
34
49
  }