@fleetbase/fleetops-engine 0.3.1 → 0.3.3

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 (264) hide show
  1. package/addon/components/admin/visibility-controls.js +1 -0
  2. package/addon/components/contact-form-panel.hbs +82 -0
  3. package/addon/components/contact-form-panel.js +195 -0
  4. package/addon/components/contact-panel/details.hbs +36 -0
  5. package/addon/components/contact-panel/details.js +3 -0
  6. package/addon/components/contact-panel.hbs +52 -0
  7. package/addon/components/contact-panel.js +161 -0
  8. package/addon/components/driver-form-panel.hbs +39 -55
  9. package/addon/components/driver-form-panel.js +41 -0
  10. package/addon/components/driver-panel/details.hbs +2 -2
  11. package/addon/components/driver-panel.hbs +12 -10
  12. package/addon/components/driver-panel.js +13 -0
  13. package/addon/components/fleet-form-panel.hbs +28 -28
  14. package/addon/components/fleet-form-panel.js +150 -1
  15. package/addon/components/fleet-listing-panel.hbs +8 -0
  16. package/addon/components/fleet-listing-panel.js +34 -0
  17. package/addon/components/fleet-panel/details.hbs +30 -0
  18. package/addon/components/fleet-panel/driver-listing.hbs +72 -0
  19. package/addon/components/fleet-panel/driver-listing.js +149 -0
  20. package/addon/components/fleet-panel/vehicle-listing.hbs +72 -0
  21. package/addon/components/fleet-panel/vehicle-listing.js +149 -0
  22. package/addon/components/fleet-panel.hbs +12 -58
  23. package/addon/components/fleet-panel.js +148 -26
  24. package/addon/components/fleet-vehicle-listing.hbs +0 -1
  25. package/addon/components/fuel-report-form-panel.hbs +41 -0
  26. package/addon/components/fuel-report-form-panel.js +122 -0
  27. package/addon/components/fuel-report-panel/details.hbs +38 -0
  28. package/addon/components/fuel-report-panel.hbs +30 -0
  29. package/addon/components/fuel-report-panel.js +161 -0
  30. package/addon/components/issue-form-panel.hbs +85 -0
  31. package/addon/components/issue-form-panel.js +211 -0
  32. package/addon/components/issue-panel/details.hbs +48 -0
  33. package/addon/components/issue-panel.hbs +30 -0
  34. package/addon/components/issue-panel.js +160 -0
  35. package/addon/components/layout/fleet-ops-sidebar.hbs +2 -2
  36. package/addon/components/layout/fleet-ops-sidebar.js +2 -1
  37. package/addon/components/live-map-drawer/driver-listing.hbs +6 -0
  38. package/addon/components/live-map-drawer/driver-listing.js +240 -0
  39. package/addon/components/live-map-drawer/place-listing.hbs +6 -0
  40. package/addon/components/live-map-drawer/place-listing.js +204 -0
  41. package/addon/components/live-map-drawer/vehicle-listing.hbs +6 -0
  42. package/addon/components/live-map-drawer/vehicle-listing.js +216 -0
  43. package/addon/components/live-map-drawer.hbs +17 -0
  44. package/addon/components/live-map-drawer.js +104 -0
  45. package/addon/components/live-map.hbs +5 -1
  46. package/addon/components/live-map.js +109 -15
  47. package/addon/components/map-container/toolbar.hbs +15 -9
  48. package/addon/components/map-container/topbar.hbs +1 -1
  49. package/addon/components/modals/issue-details.hbs +38 -0
  50. package/addon/components/modals/issue-from.hbs +138 -0
  51. package/addon/components/modals/order-event.hbs +1 -1
  52. package/addon/components/order/schedule-card.hbs +4 -4
  53. package/addon/components/order/schedule-card.js +13 -6
  54. package/addon/components/place-form-panel.hbs +50 -0
  55. package/addon/components/place-form-panel.js +134 -0
  56. package/addon/components/place-panel/details.hbs +95 -0
  57. package/addon/components/place-panel.hbs +30 -0
  58. package/addon/components/place-panel.js +161 -0
  59. package/addon/components/vehicle-form-panel.hbs +35 -44
  60. package/addon/components/vehicle-form-panel.js +41 -0
  61. package/addon/components/vehicle-panel/details.hbs +8 -2
  62. package/addon/components/vehicle-panel.hbs +8 -6
  63. package/addon/components/vendor-form-panel/create-form.hbs +114 -0
  64. package/addon/components/vendor-form-panel/create-form.js +158 -0
  65. package/addon/components/vendor-form-panel/edit-form.hbs +98 -0
  66. package/addon/components/vendor-form-panel/edit-form.js +51 -0
  67. package/addon/components/vendor-form-panel.hbs +48 -0
  68. package/addon/components/vendor-form-panel.js +226 -0
  69. package/addon/components/vendor-panel/details.hbs +77 -0
  70. package/addon/components/vendor-panel/details.js +12 -0
  71. package/addon/components/vendor-panel.hbs +58 -0
  72. package/addon/components/vendor-panel.js +161 -0
  73. package/addon/controllers/management/contacts/index/details.js +55 -0
  74. package/addon/controllers/management/contacts/index/edit.js +111 -0
  75. package/addon/controllers/management/contacts/index/new.js +88 -0
  76. package/addon/controllers/management/contacts/index.js +23 -128
  77. package/addon/controllers/management/drivers/index/new.js +2 -2
  78. package/addon/controllers/management/drivers/index.js +18 -32
  79. package/addon/controllers/management/fleets/index/details.js +53 -0
  80. package/addon/controllers/management/fleets/index/edit.js +75 -41
  81. package/addon/controllers/management/fleets/index/new.js +42 -57
  82. package/addon/controllers/management/fleets/index.js +0 -1
  83. package/addon/controllers/management/fuel-reports/index/details.js +63 -0
  84. package/addon/controllers/management/fuel-reports/index/edit.js +111 -0
  85. package/addon/controllers/management/fuel-reports/index/new.js +95 -0
  86. package/addon/controllers/management/fuel-reports/index.js +57 -127
  87. package/addon/controllers/management/issues/index/details.js +54 -0
  88. package/addon/controllers/management/issues/index/edit.js +111 -0
  89. package/addon/controllers/management/issues/index/new.js +94 -0
  90. package/addon/controllers/management/issues/index.js +131 -26
  91. package/addon/controllers/management/places/index/details.js +55 -0
  92. package/addon/controllers/management/places/index/edit.js +111 -0
  93. package/addon/controllers/management/places/index/new.js +88 -0
  94. package/addon/controllers/management/places/index.js +21 -182
  95. package/addon/controllers/management/vehicles/index/new.js +2 -6
  96. package/addon/controllers/management/vendors/index/details.js +55 -0
  97. package/addon/controllers/management/vendors/index/edit.js +111 -0
  98. package/addon/controllers/management/vendors/index/new.js +88 -0
  99. package/addon/controllers/management/vendors/index.js +43 -247
  100. package/addon/controllers/operations/orders/index.js +29 -15
  101. package/addon/controllers/operations/scheduler/index.js +45 -30
  102. package/addon/routes/management/contacts/index/details.js +14 -0
  103. package/addon/routes/management/contacts/index/edit.js +10 -0
  104. package/addon/routes/management/contacts/index/new.js +3 -0
  105. package/addon/routes/management/contacts/index.js +1 -1
  106. package/addon/routes/management/fleets/index/details.js +1 -1
  107. package/addon/routes/management/fleets/index/edit.js +1 -1
  108. package/addon/routes/management/fleets/index.js +1 -1
  109. package/addon/routes/management/fuel-reports/index/details.js +14 -0
  110. package/addon/routes/management/fuel-reports/index/edit.js +10 -0
  111. package/addon/routes/management/fuel-reports/index/new.js +3 -0
  112. package/addon/routes/management/fuel-reports/index.js +3 -1
  113. package/addon/routes/management/issues/index/details.js +14 -0
  114. package/addon/routes/management/issues/index/edit.js +10 -0
  115. package/addon/routes/management/issues/index/new.js +3 -0
  116. package/addon/routes/management/issues/index.js +1 -1
  117. package/addon/routes/management/places/index/details.js +14 -0
  118. package/addon/routes/management/places/index/edit.js +10 -0
  119. package/addon/routes/management/places/index/new.js +3 -0
  120. package/addon/routes/management/places/index.js +6 -1
  121. package/addon/routes/management/vendors/index/details.js +15 -0
  122. package/addon/routes/management/vendors/index/edit.js +11 -0
  123. package/addon/routes/management/vendors/index/new.js +3 -0
  124. package/addon/routes/management/vendors/index.js +1 -0
  125. package/addon/routes/operations/scheduler/index.js +25 -0
  126. package/addon/routes.js +27 -7
  127. package/addon/services/context-panel.js +60 -0
  128. package/addon/styles/fleetops-engine.css +28 -0
  129. package/addon/templates/management/contacts/index/details.hbs +1 -0
  130. package/addon/templates/management/contacts/index/edit.hbs +1 -0
  131. package/addon/templates/management/contacts/index/new.hbs +1 -0
  132. package/addon/templates/management/contacts/index.hbs +22 -3
  133. package/addon/templates/management/drivers/index.hbs +29 -5
  134. package/addon/templates/management/fleets/index/details.hbs +1 -1
  135. package/addon/templates/management/fleets/index/edit.hbs +1 -1
  136. package/addon/templates/management/fleets/index/new.hbs +1 -1
  137. package/addon/templates/management/fuel-reports/index/details.hbs +1 -0
  138. package/addon/templates/management/fuel-reports/index/edit.hbs +1 -0
  139. package/addon/templates/management/fuel-reports/index/new.hbs +1 -0
  140. package/addon/templates/management/fuel-reports/index.hbs +25 -4
  141. package/addon/templates/management/issues/index/details.hbs +1 -0
  142. package/addon/templates/management/issues/index/edit.hbs +1 -0
  143. package/addon/templates/management/issues/index/new.hbs +1 -0
  144. package/addon/templates/management/issues/index.hbs +5 -3
  145. package/addon/templates/management/places/index/details.hbs +1 -0
  146. package/addon/templates/management/places/index/edit.hbs +1 -0
  147. package/addon/templates/management/places/index/new.hbs +1 -0
  148. package/addon/templates/management/vendors/index/details.hbs +1 -0
  149. package/addon/templates/management/vendors/index/edit.hbs +1 -0
  150. package/addon/templates/management/vendors/index/new.hbs +1 -0
  151. package/addon/templates/operations/orders/index.hbs +5 -5
  152. package/addon/templates/operations/scheduler/index.hbs +33 -9
  153. package/addon/utils/create-full-calendar-event-from-order.js +8 -0
  154. package/app/components/contact-form-panel.js +1 -0
  155. package/app/components/contact-panel/details.js +1 -0
  156. package/app/components/contact-panel.js +1 -0
  157. package/app/components/{full-calendar/draggable.js → fleet-listing-panel.js} +1 -1
  158. package/app/components/fleet-panel/details.js +1 -0
  159. package/app/components/fleet-panel/driver-listing.js +1 -0
  160. package/app/components/fleet-panel/vehicle-listing.js +1 -0
  161. package/app/components/fuel-report-form-panel.js +1 -0
  162. package/app/components/{full-calendar.js → fuel-report-panel.js} +1 -1
  163. package/app/components/issue-form-panel.js +1 -0
  164. package/app/components/issue-panel.js +1 -0
  165. package/app/components/live-map-drawer/driver-listing.js +1 -0
  166. package/app/components/live-map-drawer/place-listing.js +1 -0
  167. package/app/components/live-map-drawer/vehicle-listing.js +1 -0
  168. package/app/components/live-map-drawer.js +1 -0
  169. package/app/components/place-form-panel.js +1 -0
  170. package/app/components/place-panel.js +1 -0
  171. package/app/components/vendor-form-panel/create-form.js +1 -0
  172. package/app/components/vendor-form-panel/edit-form.js +1 -0
  173. package/app/components/vendor-form-panel.js +1 -0
  174. package/app/components/vendor-panel/details.js +1 -0
  175. package/app/components/vendor-panel.js +1 -0
  176. package/app/controllers/management/contacts/index/details.js +1 -0
  177. package/app/controllers/management/contacts/index/edit.js +1 -0
  178. package/app/controllers/management/contacts/index/new.js +1 -0
  179. package/app/controllers/management/fuel-reports/index/details.js +1 -0
  180. package/app/controllers/management/fuel-reports/index/edit.js +1 -0
  181. package/app/controllers/management/fuel-reports/index/new.js +1 -0
  182. package/app/controllers/management/issues/index/details.js +1 -0
  183. package/app/controllers/management/issues/index/edit.js +1 -0
  184. package/app/controllers/management/issues/index/new.js +1 -0
  185. package/app/controllers/management/places/index/details.js +1 -0
  186. package/app/controllers/management/places/index/edit.js +1 -0
  187. package/app/controllers/management/places/index/new.js +1 -0
  188. package/app/controllers/management/vendors/index/edit.js +1 -0
  189. package/app/controllers/management/vendors/index/new.js +1 -0
  190. package/app/routes/addon/routes/management/places/index/new.js +1 -0
  191. package/app/routes/management/contacts/index/details.js +1 -0
  192. package/app/routes/management/contacts/index/edit.js +1 -0
  193. package/app/routes/management/contacts/index/new.js +1 -0
  194. package/app/routes/management/fuel-reports/index/details.js +1 -0
  195. package/app/routes/management/fuel-reports/index/edit.js +1 -0
  196. package/app/routes/management/fuel-reports/index/new.js +1 -0
  197. package/app/routes/management/issues/index/details.js +1 -0
  198. package/app/routes/management/issues/index/edit.js +1 -0
  199. package/app/routes/management/issues/index/new.js +1 -0
  200. package/app/routes/management/places/index/details.js +1 -0
  201. package/app/routes/management/places/index/edit.js +1 -0
  202. package/app/routes/management/places/index/new.js +1 -0
  203. package/app/routes/management/vendors/index/details.js +1 -0
  204. package/app/routes/management/vendors/index/edit.js +1 -0
  205. package/app/routes/management/vendors/index/new.js +1 -0
  206. package/app/templates/addon/routes/management/places/index/new.js +1 -0
  207. package/app/templates/management/contacts/index/details.js +1 -0
  208. package/app/templates/management/contacts/index/edit.js +1 -0
  209. package/app/templates/management/contacts/index/new.js +1 -0
  210. package/app/templates/management/fuel-reports/index/details.js +1 -0
  211. package/app/templates/management/fuel-reports/index/edit.js +1 -0
  212. package/app/templates/management/fuel-reports/index/new.js +1 -0
  213. package/app/templates/management/issues/index/details.js +1 -0
  214. package/app/templates/management/issues/index/edit.js +1 -0
  215. package/app/templates/management/issues/index/new.js +1 -0
  216. package/app/templates/management/places/index/details.js +1 -0
  217. package/app/templates/management/places/index/edit.js +1 -0
  218. package/app/templates/management/places/index/new.js +1 -0
  219. package/app/templates/management/vendors/index/details.js +1 -0
  220. package/app/templates/management/vendors/index/edit.js +1 -0
  221. package/app/templates/management/vendors/index/new.js +1 -0
  222. package/app/utils/create-full-calendar-event-from-order.js +1 -0
  223. package/composer.json +1 -1
  224. package/config/environment.js +2 -1
  225. package/extension.json +1 -1
  226. package/package.json +5 -4
  227. package/server/migrations/2023_11_03_072503_refactor_issues_table_columns.php +42 -0
  228. package/server/migrations/2023_11_06_040645_refactor_fuel_reports_table.php +38 -0
  229. package/server/src/Casts/Point.php +15 -1
  230. package/server/src/Http/Controllers/Internal/v1/DriverController.php +33 -15
  231. package/server/src/Http/Filter/FleetFilter.php +7 -0
  232. package/server/src/Http/Filter/FuelReportFilter.php +58 -0
  233. package/server/src/Http/Filter/IssueFilter.php +69 -0
  234. package/server/src/Http/Filter/VehicleFilter.php +10 -0
  235. package/server/src/Http/Middleware/TransformLocationMiddleware.php +48 -0
  236. package/server/src/Http/Resources/v1/Driver.php +1 -0
  237. package/server/src/Http/Resources/v1/Fleet.php +20 -21
  238. package/server/src/Http/Resources/v1/FuelReport.php +37 -35
  239. package/server/src/Http/Resources/v1/Issue.php +77 -0
  240. package/server/src/Http/Resources/v1/ParentFleet.php +60 -0
  241. package/server/src/Http/Resources/v1/SubFleet.php +60 -0
  242. package/server/src/Http/Resources/v1/Vehicle.php +4 -2
  243. package/server/src/Integrations/Lalamove/Lalamove.php +6 -6
  244. package/server/src/Models/Contact.php +7 -0
  245. package/server/src/Models/Driver.php +1 -1
  246. package/server/src/Models/Fleet.php +35 -4
  247. package/server/src/Models/FuelReport.php +53 -3
  248. package/server/src/Models/Issue.php +106 -7
  249. package/server/src/Models/Order.php +22 -0
  250. package/server/src/Models/Vehicle.php +1 -1
  251. package/server/src/Models/VehicleDevice.php +4 -2
  252. package/server/src/Models/VehicleDeviceEvent.php +8 -4
  253. package/server/src/Notifications/OrderAssigned.php +0 -6
  254. package/server/src/Notifications/OrderCanceled.php +0 -6
  255. package/server/src/Notifications/OrderDispatchFailed.php +0 -6
  256. package/server/src/Notifications/OrderDispatched.php +0 -6
  257. package/server/src/Notifications/OrderPing.php +0 -6
  258. package/server/src/Notifications/OrderSplit.php +0 -6
  259. package/server/src/Observers/FleetObserver.php +19 -0
  260. package/server/src/Providers/FleetOpsServiceProvider.php +1 -0
  261. package/server/src/Providers/NotificationServiceProvider.php +1 -1
  262. package/server/src/routes.php +2 -2
  263. package/addon/components/full-calendar/draggable.js +0 -1
  264. package/addon/components/full-calendar.js +0 -1
@@ -0,0 +1,69 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Filter;
4
+
5
+ use Fleetbase\FleetOps\Support\Utils;
6
+ use Fleetbase\Http\Filter\Filter;
7
+ use Illuminate\Support\Str;
8
+
9
+ class IssueFilter extends Filter
10
+ {
11
+ public function queryForInternal()
12
+ {
13
+ $this->builder->where('company_uuid', $this->session->get('company'));
14
+ }
15
+
16
+ public function query(?string $searchQuery)
17
+ {
18
+ $this->builder->search($searchQuery);
19
+ }
20
+
21
+ public function publicId(?string $publicId)
22
+ {
23
+ $this->builder->searchWhere('public_id', $publicId);
24
+ }
25
+
26
+ public function reporter(?string $reporter)
27
+ {
28
+ $this->builder->whereHas('reportedBy', function ($q) use ($reporter) {
29
+ if (Str::isUuid($reporter)) {
30
+ $q->where('uuid', $reporter);
31
+ } else {
32
+ $q->search($reporter);
33
+ }
34
+ });
35
+ }
36
+
37
+ public function assignee(?string $assignee)
38
+ {
39
+ $this->builder->whereHas('assignedBy', function ($q) use ($assignee) {
40
+ if (Str::isUuid($assignee)) {
41
+ $q->where('uuid', $assignee);
42
+ } else {
43
+ $q->search($assignee);
44
+ }
45
+ });
46
+ }
47
+
48
+ public function createdAt($createdAt)
49
+ {
50
+ $createdAt = Utils::dateRange($createdAt);
51
+
52
+ if (is_array($createdAt)) {
53
+ $this->builder->whereBetween('created_at', $createdAt);
54
+ } else {
55
+ $this->builder->whereDate('created_at', $createdAt);
56
+ }
57
+ }
58
+
59
+ public function updatedAt($updatedAt)
60
+ {
61
+ $updatedAt = Utils::dateRange($updatedAt);
62
+
63
+ if (is_array($updatedAt)) {
64
+ $this->builder->whereBetween('updated_at', $updatedAt);
65
+ } else {
66
+ $this->builder->whereDate('updated_at', $updatedAt);
67
+ }
68
+ }
69
+ }
@@ -57,6 +57,16 @@ class VehicleFilter extends Filter
57
57
  );
58
58
  }
59
59
 
60
+ public function driverUuid(?string $driverId)
61
+ {
62
+ $this->builder->whereHas(
63
+ 'driver',
64
+ function ($query) use ($driverId) {
65
+ $query->where('uuid', $driverId);
66
+ }
67
+ );
68
+ }
69
+
60
70
  public function createdAt($createdAt)
61
71
  {
62
72
  $createdAt = Utils::dateRange($createdAt);
@@ -0,0 +1,48 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Middleware;
4
+
5
+ /**
6
+ * Middleware to transform the "location" property to a default value if it is null, even if it is nested within other objects.
7
+ *
8
+ * Class TransformLocationMiddleware
9
+ */
10
+ class TransformLocationMiddleware
11
+ {
12
+ /**
13
+ * Handle an incoming request.
14
+ *
15
+ * @param Request $request
16
+ * @param Closure $next
17
+ */
18
+ public function handle($request, \Closure $next)
19
+ {
20
+ $data = $request->all();
21
+ $data = $this->transformNestedLocation($data);
22
+ $request->replace($data);
23
+
24
+ return $next($request);
25
+ }
26
+
27
+ /**
28
+ * Recursively transform the "location" property within nested objects to a default value if it is null.
29
+ *
30
+ * @param array $data the data to process
31
+ *
32
+ * @return array the transformed data
33
+ */
34
+ protected function transformNestedLocation($data)
35
+ {
36
+ foreach ($data as $key => $value) {
37
+ if (is_array($value)) {
38
+ // If the value is an array, recursively transform it
39
+ $data[$key] = $this->transformNestedLocation($value);
40
+ } elseif ($key === 'location' && $value === null) {
41
+ // Transform the 'location' property if it's null
42
+ $data[$key] = [0, 0];
43
+ }
44
+ }
45
+
46
+ return $data;
47
+ }
48
+ }
@@ -35,6 +35,7 @@ class Driver extends FleetbaseResource
35
35
  'vendor_name' => $this->when(Http::isInternalRequest(), $this->vendor_name),
36
36
  'vehicle' => $this->whenLoaded('vehicle', new VehicleWithoutDriver($this->vehicle)),
37
37
  'current_job' => $this->whenLoaded('currentJob', new CurrentJob($this->currentJob)),
38
+ 'current_job_id' => $this->when(Http::isInternalRequest(), data_get($this, 'currentJob.public_id')),
38
39
  'jobs' => $this->whenLoaded('jobs', CurrentJob::collection($this->jobs()->without(['driverAssigned'])->get())),
39
40
  'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
40
41
  'fleets' => $this->whenLoaded('fleets', Fleet::collection($this->fleets()->without('drivers')->get())),
@@ -16,27 +16,25 @@ class Fleet 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
- 'name' => $this->name,
26
- 'task' => $this->task ?? null,
27
- 'status' => $this->status ?? null,
28
- 'drivers_count' => $this->when(Http::isInternalRequest(), $this->drivers_count),
29
- 'drivers_online_count' => $this->when(Http::isInternalRequest(), $this->drivers_online_count),
30
- 'service_area' => $this->whenLoaded('serviceArea', new ServiceArea($this->serviceArea)),
31
- 'zone' => $this->whenLoaded('zone', new Zone($this->zone)),
32
- 'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
33
- 'parentFleet' => $this->whenLoaded('parent_fleet', new self($this->parent_fleet)),
34
- 'drivers' => $this->whenLoaded('drivers', Driver::collection($this->drivers()->without(['driverAssigned'])->with(Http::isInternalRequest() ? ['jobs'] : [])->get())),
35
- 'vehicles' => $this->whenLoaded('vehicles', Vehicle::collection($this->vehicles)),
36
- 'updated_at' => $this->updated_at,
37
- 'created_at' => $this->created_at,
38
- ]
39
- );
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
+ 'name' => $this->name,
24
+ 'task' => $this->task ?? null,
25
+ 'status' => $this->status ?? null,
26
+ 'drivers_count' => $this->when(Http::isInternalRequest(), $this->drivers_count),
27
+ 'drivers_online_count' => $this->when(Http::isInternalRequest(), $this->drivers_online_count),
28
+ 'service_area' => $this->whenLoaded('serviceArea', new ServiceArea($this->serviceArea)),
29
+ 'zone' => $this->whenLoaded('zone', new Zone($this->zone)),
30
+ 'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
31
+ 'parent_fleet' => $this->whenLoaded('parentFleet', new ParentFleet($this->parentFleet)),
32
+ 'subfleets' => $this->whenLoaded('subFleets', SubFleet::collection($this->subFleets)),
33
+ 'drivers' => $this->whenLoaded('drivers', Driver::collection($this->drivers()->without(['driverAssigned'])->with(Http::isInternalRequest() ? ['jobs'] : [])->get())),
34
+ 'vehicles' => $this->whenLoaded('vehicles', Vehicle::collection($this->vehicles)),
35
+ 'updated_at' => $this->updated_at,
36
+ 'created_at' => $this->created_at,
37
+ ];
40
38
  }
41
39
 
42
40
  /**
@@ -51,6 +49,7 @@ class Fleet extends FleetbaseResource
51
49
  'name' => $this->name,
52
50
  'task' => $this->task ?? null,
53
51
  'status' => $this->status ?? null,
52
+ 'parent_fleet' => $this->when($this->serviceArea, data_get($this, 'parentFleet.public_id')),
54
53
  'service_area' => $this->when($this->serviceArea, data_get($this, 'serviceArea.public_id')),
55
54
  'zone' => $this->when($this->zone, data_get($this, 'zone.public_id')),
56
55
  'updated_at' => $this->updated_at,
@@ -17,29 +17,29 @@ class FuelReport 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
- 'driver_uuid' => $this->when(Http::isInternalRequest(), $this->driver_uuid),
27
- 'vehicle_uuid' => $this->when(Http::isInternalRequest(), $this->vehicle_uuid),
28
- 'driver_name' => $this->when(Http::isInternalRequest(), $this->driver_name),
29
- 'vehicle_name' => $this->when(Http::isInternalRequest(), $this->vehicle_name),
30
- 'vehicle' => $this->whenLoaded('vehicle', new Vehicle($this->vehicle)),
31
- 'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
32
- 'odometer' => $this->odometer,
33
- 'amount' => $this->amount,
34
- 'currency' => $this->currency,
35
- 'volume' => $this->volume,
36
- 'metric_unit' => $this->metric_unit,
37
- 'type' => $this->type,
38
- 'location' => $this->location ?? new Point(0, 0),
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
+ 'reported_by_uuid' => $this->when(Http::isInternalRequest(), $this->reported_by_uuid),
25
+ 'driver_uuid' => $this->when(Http::isInternalRequest(), $this->driver_uuid),
26
+ 'vehicle_uuid' => $this->when(Http::isInternalRequest(), $this->vehicle_uuid),
27
+ 'reporter_name' => $this->when(Http::isInternalRequest(), $this->reporter_name),
28
+ 'driver_name' => $this->when(Http::isInternalRequest(), $this->driver_name),
29
+ 'vehicle_name' => $this->when(Http::isInternalRequest(), $this->vehicle_name),
30
+ 'reporter' => $this->whenLoaded('reporter', $this->reporter),
31
+ 'vehicle' => $this->whenLoaded('vehicle', new Vehicle($this->vehicle)),
32
+ 'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
33
+ 'odometer' => $this->odometer,
34
+ 'amount' => $this->amount,
35
+ 'currency' => $this->currency,
36
+ 'volume' => $this->volume,
37
+ 'metric_unit' => $this->metric_unit,
38
+ 'type' => $this->type,
39
+ 'location' => $this->location ?? new Point(0, 0),
40
+ 'updated_at' => $this->updated_at,
41
+ 'created_at' => $this->created_at,
42
+ ];
43
43
  }
44
44
 
45
45
  /**
@@ -50,18 +50,20 @@ class FuelReport extends FleetbaseResource
50
50
  public function toWebhookPayload()
51
51
  {
52
52
  return [
53
- 'id' => $this->public_id,
54
- 'driver' => data_get($this, 'driver.public_id'),
55
- 'vehicle' => data_get($this, 'vehicle.public_id'),
56
- 'odometer' => $this->odometer,
57
- 'amount' => $this->amount,
58
- 'currency' => $this->currency,
59
- 'volume' => $this->volume,
60
- 'metric_unit' => $this->metric_unit,
61
- 'type' => $this->type,
62
- 'location' => $this->location ?? new Point(0, 0),
63
- 'updated_at' => $this->updated_at,
64
- 'created_at' => $this->created_at,
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,
65
67
  ];
66
68
  }
67
69
  }
@@ -0,0 +1,77 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+ use Grimzy\LaravelMysqlSpatial\Types\Point;
8
+
9
+ class Issue extends FleetbaseResource
10
+ {
11
+ /**
12
+ * Transform the resource into an array.
13
+ *
14
+ * @param \Illuminate\Http\Request $request
15
+ *
16
+ * @return array
17
+ */
18
+ public function toArray($request)
19
+ {
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
+ 'issue_id' => $this->when(Http::isInternalRequest(), $this->issue_id),
25
+ 'driver_uuid' => $this->when(Http::isInternalRequest(), $this->driver_uuid),
26
+ 'vehicle_uuid' => $this->when(Http::isInternalRequest(), $this->vehicle_uuid),
27
+ 'assigned_to_uuid' => $this->when(Http::isInternalRequest(), $this->assigned_to_uuid),
28
+ 'reported_by_uuid' => $this->when(Http::isInternalRequest(), $this->reported_by_uuid),
29
+ 'assignee' => $this->whenLoaded('assignee', $this->assignee),
30
+ 'reporter' => $this->whenLoaded('reporter', $this->reporter),
31
+ 'vehicle' => $this->whenLoaded('vehicle', new Vehicle($this->vehicle)),
32
+ 'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
33
+ 'driver_name' => $this->driver_name,
34
+ 'vehicle_name' => $this->vehicle_name,
35
+ 'assignee_name' => $this->assignee_name,
36
+ 'reporter_name' => $this->reporter_name,
37
+ 'issue_id' => $this->issue_id,
38
+ 'report' => $this->report,
39
+ 'priority' => $this->priority,
40
+ 'meta' => data_get($this, 'meta', []),
41
+ 'type' => $this->type,
42
+ 'category' => $this->category,
43
+ 'status' => $this->status,
44
+ 'location' => data_get($this, 'location', new Point(0, 0)),
45
+ 'resolved_at' => $this->resolved_at,
46
+ 'updated_at' => $this->updated_at,
47
+ 'created_at' => $this->created_at,
48
+ ];
49
+ }
50
+
51
+ /**
52
+ * Transform the resource into an webhook payload.
53
+ *
54
+ * @return array
55
+ */
56
+ public function toWebhookPayload()
57
+ {
58
+ return [
59
+ 'id' => $this->public_id,
60
+ 'reporter' => data_get($this, 'reportedBy.public_id'),
61
+ 'assignee' => data_get($this, 'assignedTo.public_id'),
62
+ 'driver' => data_get($this, 'driver.public_id'),
63
+ 'vehicle' => data_get($this, 'vehicle.public_id'),
64
+ 'issue_id' => $this->issue_id,
65
+ 'report' => $this->report,
66
+ 'priority' => $this->priority,
67
+ 'meta' => data_get($this, 'meta', []),
68
+ 'type' => $this->type,
69
+ 'category' => $this->category,
70
+ 'status' => $this->status,
71
+ 'location' => data_get($this, 'location', new Point(0, 0)),
72
+ 'resolved_at' => $this->resolved_at,
73
+ 'updated_at' => $this->updated_at,
74
+ 'created_at' => $this->created_at,
75
+ ];
76
+ }
77
+ }
@@ -0,0 +1,60 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ class ParentFleet extends FleetbaseResource
9
+ {
10
+ /**
11
+ * Transform the resource into an array.
12
+ *
13
+ * @param \Illuminate\Http\Request $request
14
+ *
15
+ * @return array
16
+ */
17
+ public function toArray($request)
18
+ {
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
+ 'name' => $this->name,
24
+ 'task' => $this->task ?? null,
25
+ 'status' => $this->status ?? null,
26
+ 'drivers_count' => $this->when(Http::isInternalRequest(), $this->drivers_count),
27
+ 'drivers_online_count' => $this->when(Http::isInternalRequest(), $this->drivers_online_count),
28
+ 'vehicles_count' => $this->when(Http::isInternalRequest(), $this->vehicles_count),
29
+ 'vehicles_online_count' => $this->when(Http::isInternalRequest(), $this->vehicles_online_count),
30
+ 'service_area' => $this->whenLoaded('serviceArea', new ServiceArea($this->serviceArea)),
31
+ 'zone' => $this->whenLoaded('zone', new Zone($this->zone)),
32
+ 'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
33
+ 'drivers' => $this->whenLoaded('drivers', Driver::collection($this->drivers()->without(['driverAssigned'])->with(Http::isInternalRequest() ? ['jobs'] : [])->get())),
34
+ 'vehicles' => $this->whenLoaded('vehicles', Vehicle::collection($this->vehicles)),
35
+ 'subfleets' => [],
36
+ 'type' => 'fleet',
37
+ 'updated_at' => $this->updated_at,
38
+ 'created_at' => $this->created_at,
39
+ ];
40
+ }
41
+
42
+ /**
43
+ * Transform the resource into an webhook payload.
44
+ *
45
+ * @return array
46
+ */
47
+ public function toWebhookPayload()
48
+ {
49
+ return [
50
+ 'id' => $this->public_id,
51
+ 'name' => $this->name,
52
+ 'task' => $this->task ?? null,
53
+ 'status' => $this->status ?? null,
54
+ 'service_area' => $this->when($this->serviceArea, data_get($this, 'serviceArea.public_id')),
55
+ 'zone' => $this->when($this->zone, data_get($this, 'zone.public_id')),
56
+ 'updated_at' => $this->updated_at,
57
+ 'created_at' => $this->created_at,
58
+ ];
59
+ }
60
+ }
@@ -0,0 +1,60 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ class SubFleet extends FleetbaseResource
9
+ {
10
+ /**
11
+ * Transform the resource into an array.
12
+ *
13
+ * @param \Illuminate\Http\Request $request
14
+ *
15
+ * @return array
16
+ */
17
+ public function toArray($request)
18
+ {
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
+ 'name' => $this->name,
24
+ 'task' => $this->task ?? null,
25
+ 'status' => $this->status ?? null,
26
+ 'drivers_count' => $this->when(Http::isInternalRequest(), $this->drivers_count),
27
+ 'drivers_online_count' => $this->when(Http::isInternalRequest(), $this->drivers_online_count),
28
+ 'vehicles_count' => $this->when(Http::isInternalRequest(), $this->vehicles_count),
29
+ 'vehicles_online_count' => $this->when(Http::isInternalRequest(), $this->vehicles_online_count),
30
+ 'service_area' => $this->whenLoaded('serviceArea', new ServiceArea($this->serviceArea)),
31
+ 'zone' => $this->whenLoaded('zone', new Zone($this->zone)),
32
+ 'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
33
+ 'drivers' => $this->whenLoaded('drivers', Driver::collection($this->drivers()->without(['driverAssigned'])->with(Http::isInternalRequest() ? ['jobs'] : [])->get())),
34
+ 'vehicles' => $this->whenLoaded('vehicles', Vehicle::collection($this->vehicles)),
35
+ 'subfleets' => [],
36
+ 'type' => 'fleet',
37
+ 'updated_at' => $this->updated_at,
38
+ 'created_at' => $this->created_at,
39
+ ];
40
+ }
41
+
42
+ /**
43
+ * Transform the resource into an webhook payload.
44
+ *
45
+ * @return array
46
+ */
47
+ public function toWebhookPayload()
48
+ {
49
+ return [
50
+ 'id' => $this->public_id,
51
+ 'name' => $this->name,
52
+ 'task' => $this->task ?? null,
53
+ 'status' => $this->status ?? null,
54
+ 'service_area' => $this->when($this->serviceArea, data_get($this, 'serviceArea.public_id')),
55
+ 'zone' => $this->when($this->zone, data_get($this, 'zone.public_id')),
56
+ 'updated_at' => $this->updated_at,
57
+ 'created_at' => $this->created_at,
58
+ ];
59
+ }
60
+ }
@@ -23,13 +23,14 @@ class Vehicle extends FleetbaseResource
23
23
  'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
24
24
  'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
25
25
  'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
26
+ 'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
26
27
  'internal_id' => $this->internal_id,
27
28
  'name' => $this->display_name,
28
29
  'display_name' => $this->when(Http::isInternalRequest(), $this->display_name),
29
30
  'vin' => $this->vin ?? null,
30
31
  'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
31
32
  'devices' => $this->whenLoaded('devices', $this->devices),
32
- 'photo' => $this->photoUrl,
33
+ 'photo_url' => $this->photoUrl,
33
34
  'avatar_url' => $this->avatar_url,
34
35
  'make' => $this->make,
35
36
  'model' => $this->model,
@@ -65,7 +66,8 @@ class Vehicle extends FleetbaseResource
65
66
  'name' => $this->name,
66
67
  'vin' => $this->vin ?? null,
67
68
  'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
68
- 'photo' => $this->photoUrl,
69
+ 'photo_url' => $this->photoUrl,
70
+ 'avatar_url' => $this->avatar_url,
69
71
  'make' => $this->make,
70
72
  'model' => $this->model,
71
73
  'year' => $this->year,
@@ -44,17 +44,17 @@ class Lalamove
44
44
  /**
45
45
  * API Key.
46
46
  */
47
- private string $apiKey;
47
+ private ?string $apiKey;
48
48
 
49
49
  /**
50
50
  * API Secret.
51
51
  */
52
- private string $apiSecret;
52
+ private ?string $apiSecret;
53
53
 
54
54
  /**
55
55
  * Applicable request ID.
56
56
  */
57
- private string $requestId;
57
+ private ?string $requestId;
58
58
 
59
59
  /**
60
60
  * Applicable options.
@@ -272,7 +272,7 @@ class Lalamove
272
272
  return $this;
273
273
  }
274
274
 
275
- private static function sign($timestamp, string $apiSecret, string $requestMethod, string $requestPath, string $requestBody)
275
+ private static function sign($timestamp, ?string $apiSecret, ?string $requestMethod, ?string $requestPath, ?string $requestBody)
276
276
  {
277
277
  $requestMethod = strtoupper($requestMethod);
278
278
  $rawSignature = "$timestamp\r\n$requestMethod\r\n$requestPath\r\n\r\n$requestBody";
@@ -281,7 +281,7 @@ class Lalamove
281
281
  return $signature;
282
282
  }
283
283
 
284
- private function createSignature($timestamp, string $requestMethod, string $requestPath, string $requestBody)
284
+ private function createSignature($timestamp, ?string $requestMethod, ?string $requestPath, ?string $requestBody)
285
285
  {
286
286
  $requestPath = '/' . $this->namespace . '/' . $requestPath;
287
287
  $apiSecret = $this->apiSecret;
@@ -289,7 +289,7 @@ class Lalamove
289
289
  return static::sign($timestamp, $apiSecret, $requestMethod, $requestPath, $requestBody);
290
290
  }
291
291
 
292
- private function getAuthorizationKey(string $method, string $path, string $body)
292
+ private function getAuthorizationKey(?string $method, ?string $path, ?string $body)
293
293
  {
294
294
  $key = $this->apiKey;
295
295
  $timestamp = floor(microtime(true) * 1000);
@@ -84,6 +84,13 @@ class Contact extends Model
84
84
  */
85
85
  protected $hidden = ['photo'];
86
86
 
87
+ /**
88
+ * Filterable attributes/parameters.
89
+ *
90
+ * @var array
91
+ */
92
+ protected $filterParams = ['place_uuid', 'customer_type', 'facilitator_type', 'place'];
93
+
87
94
  /**
88
95
  * Properties which activity needs to be logged.
89
96
  *
@@ -144,7 +144,7 @@ class Driver extends Model
144
144
  *
145
145
  * @var array
146
146
  */
147
- protected $filterParams = ['vendor', 'facilitator', 'customer', 'fleet'];
147
+ protected $filterParams = ['vendor', 'facilitator', 'customer', 'fleet', 'photo_uuid', 'avatar_uuid'];
148
148
 
149
149
  /**
150
150
  * Properties which activity needs to be logged.