@fleetbase/fleetops-engine 0.3.7 → 0.3.9

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 (113) hide show
  1. package/addon/components/contact-form-panel.hbs +4 -1
  2. package/addon/components/contact-panel.hbs +1 -1
  3. package/addon/components/driver-form-panel.hbs +5 -12
  4. package/addon/components/driver-panel.hbs +4 -1
  5. package/addon/components/fleet-form-panel.hbs +4 -1
  6. package/addon/components/fleet-listing-panel.hbs +2 -2
  7. package/addon/components/fleet-panel.hbs +1 -1
  8. package/addon/components/fuel-report-form-panel.hbs +4 -1
  9. package/addon/components/fuel-report-panel.hbs +4 -1
  10. package/addon/components/issue-form-panel.hbs +4 -1
  11. package/addon/components/issue-panel.hbs +4 -1
  12. package/addon/components/layout/fleet-ops-sidebar/driver-listing.hbs +5 -0
  13. package/addon/components/layout/fleet-ops-sidebar/driver-listing.js +122 -0
  14. package/addon/components/layout/fleet-ops-sidebar/fleet-listing.hbs +5 -1
  15. package/addon/components/layout/fleet-ops-sidebar/fleet-listing.js +118 -1
  16. package/addon/components/layout/fleet-ops-sidebar.hbs +5 -1
  17. package/addon/components/layout/fleet-ops-sidebar.js +4 -2
  18. package/addon/components/live-map.hbs +90 -9
  19. package/addon/components/live-map.js +28 -11
  20. package/addon/components/map-container/toolbar/zones-panel.js +16 -13
  21. package/addon/components/place-form-panel.hbs +4 -1
  22. package/addon/components/place-panel.hbs +4 -1
  23. package/addon/components/settings-window.hbs +1 -1
  24. package/addon/components/vehicle-form-panel.hbs +4 -1
  25. package/addon/components/vehicle-panel.hbs +4 -1
  26. package/addon/components/vendor-form-panel.hbs +4 -1
  27. package/addon/components/vendor-panel.hbs +4 -1
  28. package/addon/controllers/management/drivers/index.js +10 -90
  29. package/addon/controllers/management/vehicles/index.js +11 -21
  30. package/addon/controllers/operations/orders/index/new.js +5 -5
  31. package/addon/controllers/operations/orders/index/view.js +9 -13
  32. package/addon/helpers/format-point.js +5 -2
  33. package/addon/helpers/point-to-coordinates.js +6 -2
  34. package/addon/services/context-panel.js +23 -18
  35. package/addon/services/driver-actions.js +107 -0
  36. package/addon/services/vehicle-actions.js +42 -0
  37. package/addon/styles/fleetops-engine.css +27 -0
  38. package/addon/templates/operations/orders/index/new.hbs +3 -3
  39. package/addon/templates/operations/service-rates/index/new.hbs +1 -1
  40. package/addon/utils/fly-to-leaflet-layer.js +7 -0
  41. package/app/components/layout/fleet-ops-sidebar/driver-listing.js +1 -0
  42. package/app/services/driver-actions.js +1 -0
  43. package/app/services/vehicle-actions.js +1 -0
  44. package/composer.json +2 -2
  45. package/extension.json +1 -1
  46. package/package.json +4 -4
  47. package/server/src/Casts/MultiPolygon.php +14 -3
  48. package/server/src/Casts/Point.php +12 -2
  49. package/server/src/Casts/Polygon.php +19 -4
  50. package/server/src/Exceptions/IntegratedVendorException.php +45 -1
  51. package/server/src/Http/Controllers/Api/v1/DriverController.php +29 -14
  52. package/server/src/Http/Controllers/Api/v1/EntityController.php +36 -1
  53. package/server/src/Http/Controllers/Api/v1/LabelController.php +2 -2
  54. package/server/src/Http/Controllers/Api/v1/OrderController.php +139 -59
  55. package/server/src/Http/Controllers/Api/v1/PayloadController.php +20 -12
  56. package/server/src/Http/Controllers/Api/v1/PlaceController.php +25 -3
  57. package/server/src/Http/Controllers/Api/v1/PurchaseRateController.php +1 -1
  58. package/server/src/Http/Controllers/Api/v1/ServiceAreaController.php +71 -3
  59. package/server/src/Http/Controllers/Api/v1/ServiceQuoteController.php +1 -1
  60. package/server/src/Http/Controllers/Api/v1/ServiceRateController.php +3 -2
  61. package/server/src/Http/Controllers/Api/v1/TrackingNumberController.php +2 -2
  62. package/server/src/Http/Controllers/Api/v1/TrackingStatusController.php +2 -2
  63. package/server/src/Http/Controllers/Api/v1/VehicleController.php +22 -2
  64. package/server/src/Http/Controllers/Api/v1/ZoneController.php +59 -3
  65. package/server/src/Http/Controllers/Internal/v1/DriverController.php +25 -4
  66. package/server/src/Http/Controllers/Internal/v1/LiveController.php +3 -10
  67. package/server/src/Http/Controllers/Internal/v1/NavigatorController.php +1 -1
  68. package/server/src/Http/Controllers/Internal/v1/OrderController.php +11 -1
  69. package/server/src/Http/Filter/TrackingStatusFilter.php +10 -0
  70. package/server/src/Http/Requests/CancelOrderRequest.php +1 -2
  71. package/server/src/Http/Requests/CreateContactRequest.php +5 -4
  72. package/server/src/Http/Requests/CreateDriverRequest.php +13 -11
  73. package/server/src/Http/Requests/CreateEntityRequest.php +7 -4
  74. package/server/src/Http/Requests/CreateOrderRequest.php +2 -2
  75. package/server/src/Http/Requests/CreatePayloadRequest.php +1 -1
  76. package/server/src/Http/Requests/CreatePlaceRequest.php +46 -4
  77. package/server/src/Http/Requests/CreatePurchaseRateRequest.php +3 -2
  78. package/server/src/Http/Requests/CreateServiceAreaRequest.php +24 -4
  79. package/server/src/Http/Requests/CreateServiceRateRequest.php +22 -21
  80. package/server/src/Http/Requests/CreateTrackingStatusRequest.php +9 -8
  81. package/server/src/Http/Requests/CreateVehicleRequest.php +6 -4
  82. package/server/src/Http/Requests/CreateZoneRequest.php +24 -5
  83. package/server/src/Http/Requests/QueryServiceQuotesRequest.php +11 -10
  84. package/server/src/Http/Requests/ScheduleOrderRequest.php +32 -0
  85. package/server/src/Http/Requests/UpdateContactRequest.php +0 -13
  86. package/server/src/Http/Requests/UpdateServiceAreaRequest.php +1 -23
  87. package/server/src/Http/Requests/UpdateServiceQuoteRequest.php +1 -23
  88. package/server/src/Http/Requests/UpdateServiceRateRequest.php +1 -23
  89. package/server/src/Http/Requests/UpdateTrackingStatusRequest.php +1 -26
  90. package/server/src/Http/Resources/v1/DeletedResource.php +2 -9
  91. package/server/src/Http/Resources/v1/Entity.php +47 -44
  92. package/server/src/Http/Resources/v1/Order.php +1 -1
  93. package/server/src/Http/Resources/v1/ServiceArea.php +2 -2
  94. package/server/src/Http/Resources/v1/Vehicle.php +1 -3
  95. package/server/src/Http/Resources/v1/Zone.php +2 -4
  96. package/server/src/Models/Entity.php +99 -3
  97. package/server/src/Models/Order.php +75 -7
  98. package/server/src/Models/Payload.php +104 -33
  99. package/server/src/Models/Place.php +56 -17
  100. package/server/src/Models/ServiceArea.php +285 -18
  101. package/server/src/Models/ServiceRate.php +10 -6
  102. package/server/src/Models/TrackingNumber.php +18 -24
  103. package/server/src/Models/TrackingStatus.php +2 -6
  104. package/server/src/Models/Vehicle.php +2 -2
  105. package/server/src/Models/Waypoint.php +0 -10
  106. package/server/src/Models/Zone.php +132 -5
  107. package/server/src/Support/Flow.php +17 -3
  108. package/server/src/Support/Utils.php +143 -9
  109. package/server/src/routes.php +4 -3
  110. package/addon/helpers/extract-coordinates.js +0 -6
  111. package/addon/utils/extract-coordinates.js +0 -1
  112. package/app/helpers/extract-coordinates.js +0 -1
  113. package/app/utils/extract-coordinates.js +0 -1
@@ -28,7 +28,7 @@ class CreatePayloadRequest extends FleetbaseRequest
28
28
  'entities' => 'array',
29
29
  'waypoints' => 'array',
30
30
  'return' => 'nullable',
31
- 'type' => 'required',
31
+ 'type' => [Rule::requiredIf($this->isMethod('POST'))],
32
32
  'cod_currency' => [Rule::requiredIf($this->has(['cod_amount'])), 'size:3'],
33
33
  'cod_payment_method' => [Rule::requiredIf($this->has(['cod_amount'])), 'in:card,check,cash,bank_transfer'],
34
34
  ];
@@ -29,14 +29,56 @@ class CreatePlaceRequest extends FleetbaseRequest
29
29
  public function rules()
30
30
  {
31
31
  return [
32
- 'name' => [Rule::requiredIf($this->isMethod('POST'))],
33
- 'street1' => [Rule::requiredIf($this->isMethod('POST'))],
32
+ 'name' => [
33
+ Rule::requiredIf(function () {
34
+ $isCreating = $this->isMethod('POST');
35
+ $hasCoordiantes = $this->filled('latitude') && $this->filled('longitude');
36
+ $hasLocation = $this->filled('location');
37
+ $hasStreet = $this->filled('street1');
38
+
39
+ // if creating then it's required
40
+ if ($isCreating) {
41
+ // if either has coordinated or location then it's not required
42
+ if ($hasCoordiantes || $hasLocation) {
43
+ return false;
44
+ }
45
+
46
+ // if street1 provided then it's not required
47
+ if ($hasStreet) {
48
+ return false;
49
+ }
50
+
51
+ return true;
52
+ }
53
+
54
+ return false;
55
+ }),
56
+ ],
57
+ 'street1' => [
58
+ Rule::requiredIf(function () {
59
+ $isCreating = $this->isMethod('POST');
60
+ $hasCoordiantes = $this->filled('latitude') && $this->filled('longitude');
61
+ $hasLocation = $this->filled('location');
62
+
63
+ // if creating then it's required
64
+ if ($isCreating) {
65
+ // if either has coordinated or location then it's not required
66
+ if ($hasCoordiantes || $hasLocation) {
67
+ return false;
68
+ }
69
+
70
+ return true;
71
+ }
72
+
73
+ return false;
74
+ }),
75
+ ],
34
76
  'customer' => ['nullable', new ExistsInAny(['vendors', 'contacts'], 'public_id')],
35
77
  'contact' => ['nullable', new ExistsInAny(['vendors', 'contacts'], 'public_id')],
36
78
  'vendor' => 'nullable|exists:vendors,public_id',
37
79
  'location' => ['nullable', new ResolvablePoint()],
38
- 'latitude' => 'nullable',
39
- 'longitude' => 'nullable',
80
+ 'latitude' => ['nullable', 'required_with:longitude'],
81
+ 'longitude' => ['nullable', 'required_with:latitude'],
40
82
  ];
41
83
  }
42
84
  }
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
5
  use Fleetbase\Http\Requests\FleetbaseRequest;
6
6
  use Fleetbase\Rules\ExistsInAny;
7
+ use Illuminate\Validation\Rule;
7
8
 
8
9
  class CreatePurchaseRateRequest extends FleetbaseRequest
9
10
  {
@@ -25,8 +26,8 @@ class CreatePurchaseRateRequest extends FleetbaseRequest
25
26
  public function rules()
26
27
  {
27
28
  return [
28
- 'service_quote' => 'required|exists:service_quotes,public_id',
29
- 'order' => 'nullable|exists:orders,public_id',
29
+ 'service_quote' => ['required', Rule::exists('service_quotes', 'public_id')->whereNull('deleted_at')],
30
+ 'order' => ['nullable', Rule::exists('orders', 'public_id')->whereNull('deleted_at')],
30
31
  'customer' => ['nullable', new ExistsInAny(['vendors', 'contacts'], 'public_id')],
31
32
  ];
32
33
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
+ use Fleetbase\FleetOps\Rules\ResolvablePoint;
5
6
  use Fleetbase\Http\Requests\FleetbaseRequest;
6
7
  use Illuminate\Validation\Rule;
7
8
 
@@ -14,9 +15,7 @@ class CreateServiceAreaRequest extends FleetbaseRequest
14
15
  */
15
16
  public function authorize()
16
17
  {
17
- return request()
18
- ->session()
19
- ->has('api_credential');
18
+ return request()->session()->has('api_credential');
20
19
  }
21
20
 
22
21
  /**
@@ -28,8 +27,29 @@ class CreateServiceAreaRequest extends FleetbaseRequest
28
27
  {
29
28
  return [
30
29
  'name' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
31
- 'country' => 'required',
30
+ 'country' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
32
31
  'status' => 'in:active,inactive',
32
+ 'border' => ['nullable', Rule::requiredIf(function () {
33
+ $isCreating = $this->isMethod('POST');
34
+ $hasCoordiantes = $this->filled('latitude') && $this->filled('longitude');
35
+ $hasLocation = $this->filled('location');
36
+
37
+ // if creating then it's required
38
+ if ($isCreating) {
39
+ // if either has coordinated or location then it's not required
40
+ if ($hasCoordiantes || $hasLocation) {
41
+ return false;
42
+ }
43
+
44
+ return true;
45
+ }
46
+
47
+ return false;
48
+ })],
49
+ 'parent' => ['nullable', 'exists:service_areas,public_id'],
50
+ 'location' => ['nullable', new ResolvablePoint()],
51
+ 'latitude' => ['nullable', 'required_with:longitude'],
52
+ 'longitude' => ['nullable', 'required_with:latitude'],
33
53
  ];
34
54
  }
35
55
  }
@@ -29,28 +29,29 @@ class CreateServiceRateRequest extends FleetbaseRequest
29
29
  return [
30
30
  'service_name' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
31
31
  'service_type' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
32
- 'service_area' => 'exists:service_areas,public_id',
33
- 'zone' => 'exists:zones,public_id',
34
- 'rate_calculation_method' => 'required|string|in:per_km,fixed_meter,algo',
35
- 'currency' => 'required|size:3',
36
- 'base_fee' => 'integer',
37
- 'per_km_flat_rate_fee' => [Rule::requiredIf($this->input(['rate_calculation_method']) === 'rate_calculation_method'), 'integer'],
38
- 'meter_fees' => [Rule::requiredIf($this->input(['rate_calculation_method']) === 'fixed_meter'), 'array'],
39
- 'meter_fees.*.distance' => 'integer',
40
- 'meter_fees.*.fee' => 'integer',
41
- 'algorithm' => [Rule::requiredIf($this->input(['rate_calculation_method']) === 'algo'), new ComputableAlgo(), 'string'],
42
- 'has_cod_fee' => 'boolean',
32
+ 'service_area' => [Rule::exists('service_areas', 'public_id')->whereNull('deleted_at')],
33
+ 'zone' => [Rule::exists('zones', 'public_id')->whereNull('deleted_at')],
34
+ 'rate_calculation_method' => [Rule::requiredIf($this->isMethod('POST')), 'string', 'in:fixed_meter,per_meter,per_drop,algo'],
35
+ 'currency' => ['required', 'size:3'],
36
+ 'base_fee' => ['numeric'],
37
+ 'per_meter_unit' => ['required_if:rate_calculation_method,per_meter', 'string', 'in:km,m'],
38
+ 'per_meter_flat_rate_fee' => ['required_if:rate_calculation_method,per_meter', 'numeric'],
39
+ 'meter_fees' => ['required_if:rate_calculation_method,fixed_meter', 'array'],
40
+ 'meter_fees.*.distance' => ['numeric'],
41
+ 'meter_fees.*.fee' => ['numeric'],
42
+ 'algorithm' => ['required_if:rate_calculation_method,algo', new ComputableAlgo(), 'string'],
43
+ 'has_cod_fee' => ['boolean'],
43
44
  'cod_calculation_method' => [Rule::requiredIf(Utils::isTrue($this->input(['has_cod_fee']))), 'in:percentage,flat'],
44
- 'cod_flat_fee' => [Rule::requiredIf($this->input(['cod_calculation_method']) === 'flat'), 'integer'],
45
- 'cod_percent' => [Rule::requiredIf($this->input(['cod_calculation_method']) === 'percentage'), 'integer'],
46
- 'has_peak_hours_fee' => 'boolean',
47
- 'peak_hours_calculation_method' => [Rule::requiredIf(Utils::isTrue($this->input(['has_peak_hours']))), 'in:percentage,flat'],
48
- 'peak_hours_flat_fee' => [Rule::requiredIf($this->input(['peak_hours_calculation_method']) === 'flat'), 'integer'],
49
- 'peak_hours_percent' => [Rule::requiredIf($this->input(['peak_hours_calculation_method']) === 'percentage'), 'integer'],
50
- 'peak_hours_start' => [Rule::requiredIf(Utils::isTrue($this->input(['has_peak_hours']))), 'date_format:H:i'],
51
- 'peak_hours_end' => [Rule::requiredIf(Utils::isTrue($this->input(['has_peak_hours']))), 'date_format:H:i'],
52
- 'duration_terms' => 'string',
53
- 'estimated_days' => 'numeric',
45
+ 'cod_flat_fee' => [Rule::requiredIf($this->input('cod_calculation_method') === 'flat'), 'numeric'],
46
+ 'cod_percent' => [Rule::requiredIf($this->input('cod_calculation_method') === 'percentage'), 'integer'],
47
+ 'has_peak_hours_fee' => ['boolean'],
48
+ 'peak_hours_calculation_method' => [Rule::requiredIf(Utils::isTrue($this->input('has_peak_hours'))), 'in:percentage,flat'],
49
+ 'peak_hours_flat_fee' => [Rule::requiredIf($this->input('peak_hours_calculation_method') === 'flat'), 'numeric'],
50
+ 'peak_hours_percent' => [Rule::requiredIf($this->input('peak_hours_calculation_method') === 'percentage'), 'integer'],
51
+ 'peak_hours_start' => [Rule::requiredIf(Utils::isTrue($this->input('has_peak_hours'))), 'date_format:H:i'],
52
+ 'peak_hours_end' => [Rule::requiredIf(Utils::isTrue($this->input('has_peak_hours'))), 'date_format:H:i'],
53
+ 'duration_terms' => ['string'],
54
+ 'estimated_days' => ['integer'],
54
55
  ];
55
56
  }
56
57
  }
@@ -30,14 +30,15 @@ class CreateTrackingStatusRequest extends FleetbaseRequest
30
30
  {
31
31
  $validations = [
32
32
  'tracking_number' => array_filter([
33
- 'required',
33
+ Rule::requiredIf($this->isMethod('POST')),
34
34
  $this->isMethod('POST') ? Rule::exists('tracking_numbers', 'public_id') : null,
35
35
  $this->isMethod('POST') ? static::uniqueStatus($this) : null,
36
36
  ]),
37
- 'location' => [new ResolvablePoint()],
38
- 'code' => 'nullable|string|min:3',
39
- 'status' => ['required', 'string', 'min:3'],
40
- 'details' => 'nullable|string',
37
+ 'location' => [Rule::requiredIf($this->isMethod('POST')), new ResolvablePoint()],
38
+ 'country' => ['nullable', 'string', 'size:2'],
39
+ 'code' => [Rule::requiredIf($this->isMethod('POST')), 'string', 'min:3'],
40
+ 'status' => [Rule::requiredIf($this->isMethod('POST')), 'string', 'min:3'],
41
+ 'details' => [Rule::requiredIf($this->isMethod('POST')), 'string', 'min:3'],
41
42
  ];
42
43
 
43
44
  if ($this->isMethod('POST') && $this->missing('tracking_number') && $this->has('order')) {
@@ -50,10 +51,10 @@ class CreateTrackingStatusRequest extends FleetbaseRequest
50
51
  }
51
52
 
52
53
  if ($this->missing(['latitude', 'longitude'])) {
53
- $validations['location'] = ['required', new ResolvablePoint()];
54
+ $validations['location'] = [Rule::requiredIf($this->isMethod('POST')), new ResolvablePoint()];
54
55
  } elseif ($this->missing('location')) {
55
- $validations['latitude'] = 'required';
56
- $validations['longitude'] = 'required';
56
+ $validations['latitude'] = [Rule::requiredIf($this->isMethod('POST'))];
57
+ $validations['longitude'] = [Rule::requiredIf($this->isMethod('POST'))];
57
58
  }
58
59
 
59
60
  return $validations;
@@ -25,10 +25,12 @@ class CreateVehicleRequest extends FleetbaseRequest
25
25
  public function rules()
26
26
  {
27
27
  return [
28
- 'status' => 'nullable|in:operational,maintenance,decommissioned',
29
- 'vendor' => 'nullable|exists:vendors,public_id',
30
- 'driver' => 'nullable|exists:drivers,public_id',
31
- 'location' => ['nullable', new ResolvablePoint()],
28
+ 'status' => 'nullable|in:operational,maintenance,decommissioned',
29
+ 'vendor' => 'nullable|exists:vendors,public_id',
30
+ 'driver' => 'nullable|exists:drivers,public_id',
31
+ 'location' => ['nullable', new ResolvablePoint()],
32
+ 'latitude' => ['nullable', 'required_with:longitude'],
33
+ 'longitude' => ['nullable', 'required_with:latitude'],
32
34
  ];
33
35
  }
34
36
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
+ use Fleetbase\FleetOps\Rules\ResolvablePoint;
5
6
  use Fleetbase\Http\Requests\FleetbaseRequest;
6
7
  use Illuminate\Validation\Rule;
7
8
 
@@ -25,11 +26,29 @@ class CreateZoneRequest extends FleetbaseRequest
25
26
  public function rules()
26
27
  {
27
28
  return [
28
- 'name' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
29
- // @todo properly validate boundary param
30
- 'boundary' => 'required|array',
31
- 'service_area' => 'required|exists:service_areas,public_id',
32
- 'status' => 'nullable|in:active,inactive',
29
+ 'name' => [Rule::requiredIf($this->isMethod('POST')), 'string'],
30
+ 'service_area' => [Rule::requiredIf($this->isMethod('POST')), 'exists:service_areas,public_id'],
31
+ 'border' => ['nullable', Rule::requiredIf(function () {
32
+ $isCreating = $this->isMethod('POST');
33
+ $hasCoordiantes = $this->filled('latitude') && $this->filled('longitude');
34
+ $hasLocation = $this->filled('location');
35
+
36
+ // if creating then it's required
37
+ if ($isCreating) {
38
+ // if either has coordinated or location then it's not required
39
+ if ($hasCoordiantes || $hasLocation) {
40
+ return false;
41
+ }
42
+
43
+ return true;
44
+ }
45
+
46
+ return false;
47
+ })],
48
+ 'location' => ['nullable', new ResolvablePoint()],
49
+ 'latitude' => ['nullable', 'required_with:longitude'],
50
+ 'longitude' => ['nullable', 'required_with:latitude'],
51
+ 'status' => ['nullable', 'in:active,inactive'],
33
52
  ];
34
53
  }
35
54
  }
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
5
  use Fleetbase\Http\Requests\FleetbaseRequest;
6
6
  use Fleetbase\Rules\ExistsInAny;
7
+ use Illuminate\Validation\Rule;
7
8
 
8
9
  class QueryServiceQuotesRequest extends FleetbaseRequest
9
10
  {
@@ -25,17 +26,17 @@ class QueryServiceQuotesRequest extends FleetbaseRequest
25
26
  public function rules()
26
27
  {
27
28
  return [
28
- 'payload' => 'nullable|exists:payloads,public_id',
29
- 'service_type' => 'nullable|exists:service_rates,service_type',
30
- 'pickup' => 'nullable|required_without:payload,waypoints',
31
- 'dropoff' => 'nullable|required_without:payload,waypoints',
32
- 'waypoints' => 'nullable|array',
29
+ 'payload' => ['nullable', 'required_without_all:waypoints,pickup,dropoff', Rule::exists('payloads', 'public_id')->whereNull('deleted_at')],
30
+ 'service_type' => ['nullable', Rule::exists('service_rates', 'service_type')->whereNull('deleted_at')],
31
+ 'pickup' => ['nullable', 'required_without_all:payload,waypoints'],
32
+ 'dropoff' => ['nullable', 'required_without_all:payload,waypoints'],
33
+ 'waypoints' => ['nullable', 'array', 'required_without_all:payload,pickup,dropoff'],
33
34
  'facilitator' => ['nullable', new ExistsInAny(['vendors', 'integrated_vendors', 'contacts'], ['public_id', 'provider'])],
34
- 'scheduled_at' => 'nullable|date',
35
- 'cod' => 'nullable',
36
- 'currency' => 'nullable',
37
- 'distance' => 'nullable',
38
- 'time' => 'nullable',
35
+ 'scheduled_at' => ['nullable', 'date'],
36
+ 'cod' => ['nullable'],
37
+ 'currency' => ['nullable', 'string', 'size:3'],
38
+ 'distance' => ['nullable'],
39
+ 'time' => ['nullable'],
39
40
  ];
40
41
  }
41
42
  }
@@ -0,0 +1,32 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Requests;
4
+
5
+ use Fleetbase\Http\Requests\FleetbaseRequest;
6
+
7
+ class ScheduleOrderRequest extends FleetbaseRequest
8
+ {
9
+ /**
10
+ * Determine if the user is authorized to make this request.
11
+ *
12
+ * @return bool
13
+ */
14
+ public function authorize()
15
+ {
16
+ return request()->session()->has('api_credential');
17
+ }
18
+
19
+ /**
20
+ * Get the validation rules that apply to the request.
21
+ *
22
+ * @return array
23
+ */
24
+ public function rules()
25
+ {
26
+ return [
27
+ 'date' => 'required|date_format:Y-m-d',
28
+ 'time' => 'nullable',
29
+ 'timezone' => 'nullable|timezone',
30
+ ];
31
+ }
32
+ }
@@ -4,17 +4,4 @@ namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
5
  class UpdateContactRequest extends CreateContactRequest
6
6
  {
7
- /**
8
- * Get the validation rules that apply to the request.
9
- *
10
- * @return array
11
- */
12
- public function rules()
13
- {
14
- return [
15
- 'name' => 'required',
16
- 'email' => 'nullable|email',
17
- 'phone' => 'nullable',
18
- ];
19
- }
20
7
  }
@@ -2,28 +2,6 @@
2
2
 
3
3
  namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
- use Fleetbase\Http\Requests\FleetbaseRequest;
6
-
7
- class UpdateServiceAreaRequest extends FleetbaseRequest
5
+ class UpdateServiceAreaRequest extends CreateServiceAreaRequest
8
6
  {
9
- /**
10
- * Determine if the user is authorized to make this request.
11
- *
12
- * @return bool
13
- */
14
- public function authorize()
15
- {
16
- return false;
17
- }
18
-
19
- /**
20
- * Get the validation rules that apply to the request.
21
- *
22
- * @return array
23
- */
24
- public function rules()
25
- {
26
- return [
27
- ];
28
- }
29
7
  }
@@ -2,28 +2,6 @@
2
2
 
3
3
  namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
- use Fleetbase\Http\Requests\FleetbaseRequest;
6
-
7
- class UpdateServiceQuoteRequest extends FleetbaseRequest
5
+ class UpdateServiceQuoteRequest extends CreateServiceQuoteRequest
8
6
  {
9
- /**
10
- * Determine if the user is authorized to make this request.
11
- *
12
- * @return bool
13
- */
14
- public function authorize()
15
- {
16
- return false;
17
- }
18
-
19
- /**
20
- * Get the validation rules that apply to the request.
21
- *
22
- * @return array
23
- */
24
- public function rules()
25
- {
26
- return [
27
- ];
28
- }
29
7
  }
@@ -2,28 +2,6 @@
2
2
 
3
3
  namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
- use Fleetbase\Http\Requests\FleetbaseRequest;
6
-
7
- class UpdateServiceRateRequest extends FleetbaseRequest
5
+ class UpdateServiceRateRequest extends CreateServiceRateRequest
8
6
  {
9
- /**
10
- * Determine if the user is authorized to make this request.
11
- *
12
- * @return bool
13
- */
14
- public function authorize()
15
- {
16
- return false;
17
- }
18
-
19
- /**
20
- * Get the validation rules that apply to the request.
21
- *
22
- * @return array
23
- */
24
- public function rules()
25
- {
26
- return [
27
- ];
28
- }
29
7
  }
@@ -2,31 +2,6 @@
2
2
 
3
3
  namespace Fleetbase\FleetOps\Http\Requests;
4
4
 
5
- use Fleetbase\Http\Requests\FleetbaseRequest;
6
-
7
- class UpdateTrackingStatusRequest extends FleetbaseRequest
5
+ class UpdateTrackingStatusRequest extends CreateTrackingStatusRequest
8
6
  {
9
- /**
10
- * Determine if the user is authorized to make this request.
11
- *
12
- * @return bool
13
- */
14
- public function authorize()
15
- {
16
- return request()->session()->has('api_credential');
17
- }
18
-
19
- /**
20
- * Get the validation rules that apply to the request.
21
- *
22
- * @return array
23
- */
24
- public function rules()
25
- {
26
- return [
27
- 'status' => 'required|string',
28
- 'details' => 'required|string',
29
- 'code' => 'nullable|string',
30
- ];
31
- }
32
7
  }
@@ -5,7 +5,6 @@ namespace Fleetbase\FleetOps\Http\Resources\v1;
5
5
  use Fleetbase\FleetOps\Support\Utils;
6
6
  use Fleetbase\Http\Resources\FleetbaseResource;
7
7
  use Fleetbase\Support\Http;
8
- use Illuminate\Support\Arr;
9
8
 
10
9
  class DeletedResource extends FleetbaseResource
11
10
  {
@@ -18,7 +17,7 @@ class DeletedResource extends FleetbaseResource
18
17
  */
19
18
  public function toArray($request)
20
19
  {
21
- $deleted = [
20
+ return [
22
21
  'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
22
  'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
23
  'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
@@ -26,12 +25,6 @@ class DeletedResource extends FleetbaseResource
26
25
  'time' => $this->deleted_at,
27
26
  'deleted' => true,
28
27
  ];
29
-
30
- if (Http::isInternalRequest()) {
31
- $deleted = Arr::insertAfterKey($deleted, ['uuid' => $this->uuid, 'public_id' => $this->public_id], 'id');
32
- }
33
-
34
- return $deleted;
35
28
  }
36
29
 
37
30
  /**
@@ -56,6 +49,6 @@ class DeletedResource extends FleetbaseResource
56
49
  */
57
50
  public function getObjectType()
58
51
  {
59
- return strtolower(Utils::getClassName($this->resource));
52
+ return Utils::getTypeFromClassName($this->resource);
60
53
  }
61
54
  }