@fleetbase/fleetops-engine 0.3.7 → 0.3.8
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.
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.hbs +5 -1
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.js +98 -1
- package/addon/components/layout/fleet-ops-sidebar.hbs +5 -1
- package/addon/components/layout/fleet-ops-sidebar.js +1 -0
- package/addon/styles/fleetops-engine.css +17 -0
- package/addon/templates/operations/service-rates/index/new.hbs +1 -1
- package/composer.json +2 -2
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/src/Casts/MultiPolygon.php +14 -3
- package/server/src/Casts/Point.php +12 -2
- package/server/src/Casts/Polygon.php +19 -4
- package/server/src/Http/Controllers/Api/v1/DriverController.php +27 -12
- package/server/src/Http/Controllers/Api/v1/EntityController.php +36 -1
- package/server/src/Http/Controllers/Api/v1/LabelController.php +2 -2
- package/server/src/Http/Controllers/Api/v1/OrderController.php +139 -59
- package/server/src/Http/Controllers/Api/v1/PayloadController.php +20 -12
- package/server/src/Http/Controllers/Api/v1/PlaceController.php +25 -3
- package/server/src/Http/Controllers/Api/v1/PurchaseRateController.php +1 -1
- package/server/src/Http/Controllers/Api/v1/ServiceAreaController.php +71 -3
- package/server/src/Http/Controllers/Api/v1/ServiceQuoteController.php +1 -1
- package/server/src/Http/Controllers/Api/v1/ServiceRateController.php +3 -2
- package/server/src/Http/Controllers/Api/v1/TrackingNumberController.php +2 -2
- package/server/src/Http/Controllers/Api/v1/TrackingStatusController.php +2 -2
- package/server/src/Http/Controllers/Api/v1/VehicleController.php +22 -2
- package/server/src/Http/Controllers/Api/v1/ZoneController.php +59 -3
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +11 -1
- package/server/src/Http/Filter/TrackingStatusFilter.php +10 -0
- package/server/src/Http/Requests/CancelOrderRequest.php +1 -2
- package/server/src/Http/Requests/CreateContactRequest.php +5 -4
- package/server/src/Http/Requests/CreateDriverRequest.php +13 -11
- package/server/src/Http/Requests/CreateEntityRequest.php +7 -4
- package/server/src/Http/Requests/CreateOrderRequest.php +2 -2
- package/server/src/Http/Requests/CreatePayloadRequest.php +1 -1
- package/server/src/Http/Requests/CreatePlaceRequest.php +46 -4
- package/server/src/Http/Requests/CreatePurchaseRateRequest.php +3 -2
- package/server/src/Http/Requests/CreateServiceAreaRequest.php +24 -4
- package/server/src/Http/Requests/CreateServiceRateRequest.php +22 -21
- package/server/src/Http/Requests/CreateTrackingStatusRequest.php +9 -8
- package/server/src/Http/Requests/CreateVehicleRequest.php +6 -4
- package/server/src/Http/Requests/CreateZoneRequest.php +24 -5
- package/server/src/Http/Requests/QueryServiceQuotesRequest.php +11 -10
- package/server/src/Http/Requests/ScheduleOrderRequest.php +32 -0
- package/server/src/Http/Requests/UpdateContactRequest.php +0 -13
- package/server/src/Http/Requests/UpdateServiceAreaRequest.php +1 -23
- package/server/src/Http/Requests/UpdateServiceQuoteRequest.php +1 -23
- package/server/src/Http/Requests/UpdateServiceRateRequest.php +1 -23
- package/server/src/Http/Requests/UpdateTrackingStatusRequest.php +1 -26
- package/server/src/Http/Resources/v1/DeletedResource.php +2 -9
- package/server/src/Http/Resources/v1/Entity.php +47 -44
- package/server/src/Http/Resources/v1/Order.php +1 -1
- package/server/src/Http/Resources/v1/ServiceArea.php +2 -2
- package/server/src/Http/Resources/v1/Vehicle.php +1 -3
- package/server/src/Http/Resources/v1/Zone.php +2 -4
- package/server/src/Models/Entity.php +99 -3
- package/server/src/Models/Order.php +75 -7
- package/server/src/Models/Payload.php +104 -33
- package/server/src/Models/Place.php +56 -17
- package/server/src/Models/ServiceArea.php +285 -18
- package/server/src/Models/ServiceRate.php +10 -6
- package/server/src/Models/TrackingNumber.php +18 -24
- package/server/src/Models/TrackingStatus.php +2 -6
- package/server/src/Models/Vehicle.php +2 -2
- package/server/src/Models/Waypoint.php +0 -10
- package/server/src/Models/Zone.php +132 -5
- package/server/src/Support/Flow.php +17 -3
- package/server/src/Support/Utils.php +143 -9
- package/server/src/routes.php +4 -3
|
@@ -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
|
|
29
|
-
'service_type' => 'nullable
|
|
30
|
-
'pickup' => 'nullable
|
|
31
|
-
'dropoff' => 'nullable
|
|
32
|
-
'waypoints' => 'nullable
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
52
|
+
return Utils::getTypeFromClassName($this->resource);
|
|
60
53
|
}
|
|
61
54
|
}
|
|
@@ -19,36 +19,39 @@ class Entity extends FleetbaseResource
|
|
|
19
19
|
public function toArray($request)
|
|
20
20
|
{
|
|
21
21
|
return [
|
|
22
|
-
'id'
|
|
23
|
-
'uuid'
|
|
24
|
-
'photo_uuid'
|
|
25
|
-
'public_id'
|
|
26
|
-
'customer_uuid'
|
|
27
|
-
'customer_type'
|
|
28
|
-
'supplier_uuid'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
22
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
23
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
24
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
25
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
26
|
+
'customer_uuid' => $this->when(Http::isInternalRequest(), $this->customer_uuid),
|
|
27
|
+
'customer_type' => $this->when(Http::isInternalRequest(), $this->customer_type),
|
|
28
|
+
'supplier_uuid' => $this->when(Http::isInternalRequest(), $this->supplier_uuid),
|
|
29
|
+
'destination_uuid' => $this->when(Http::isInternalRequest(), $this->destination_uuid),
|
|
30
|
+
'payload_uuid' => $this->when(Http::isInternalRequest(), $this->payload_uuid),
|
|
31
|
+
'internal_id' => $this->internal_id,
|
|
32
|
+
'name' => $this->name,
|
|
33
|
+
'type' => $this->type,
|
|
34
|
+
'payload' => $this->when(Http::isPublicRequest(), data_get($this, 'payload.public_id'), null),
|
|
35
|
+
'destination' => $this->when(Http::isPublicRequest(), data_get($this, 'destination.public_id'), null),
|
|
36
|
+
'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
|
|
37
|
+
'supplier' => $this->whenLoaded('supplier', $this->supplier),
|
|
38
|
+
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
39
|
+
'description' => data_get($this, 'description'),
|
|
40
|
+
'photo_url' => data_get($this, 'photo_url'),
|
|
41
|
+
'length' => data_get($this, 'length'),
|
|
42
|
+
'width' => data_get($this, 'width'),
|
|
43
|
+
'height' => data_get($this, 'height'),
|
|
44
|
+
'dimensions_unit' => data_get($this, 'dimensions_unit'),
|
|
45
|
+
'weight' => data_get($this, 'weight'),
|
|
46
|
+
'weight_unit' => data_get($this, 'weight_unit'),
|
|
47
|
+
'declared_value' => data_get($this, 'declared_value'),
|
|
48
|
+
'price' => data_get($this, 'price'),
|
|
49
|
+
'sale_price' => data_get($this, 'sale_price'),
|
|
50
|
+
'sku' => data_get($this, 'sku'),
|
|
51
|
+
'currency' => data_get($this, 'currency'),
|
|
52
|
+
'meta' => data_get($this, 'meta', []),
|
|
53
|
+
'updated_at' => $this->updated_at,
|
|
54
|
+
'created_at' => $this->created_at,
|
|
52
55
|
];
|
|
53
56
|
}
|
|
54
57
|
|
|
@@ -82,23 +85,23 @@ class Entity extends FleetbaseResource
|
|
|
82
85
|
'id' => $this->public_id,
|
|
83
86
|
'internal_id' => $this->internal_id,
|
|
84
87
|
'name' => $this->name,
|
|
85
|
-
'type' => $this
|
|
88
|
+
'type' => data_get($this, 'type'),
|
|
86
89
|
'destination' => $this->destination ? $this->destination->public_id : null,
|
|
87
90
|
'customer' => Resolve::resourceForMorph($this->customer_type, $this->customer_uuid),
|
|
88
91
|
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
89
|
-
'description' => $this
|
|
90
|
-
'photo_url' => $this
|
|
91
|
-
'length' => $this
|
|
92
|
-
'width' => $this
|
|
93
|
-
'height' => $this
|
|
94
|
-
'dimensions_unit' => $this
|
|
95
|
-
'weight' => $this
|
|
96
|
-
'weight_unit' => $this
|
|
97
|
-
'declared_value' => $this
|
|
98
|
-
'price' => $this
|
|
99
|
-
'sale_price' => $this
|
|
100
|
-
'sku' => $this
|
|
101
|
-
'currency' => $this
|
|
92
|
+
'description' => data_get($this, 'description'),
|
|
93
|
+
'photo_url' => data_get($this, 'photo_url'),
|
|
94
|
+
'length' => data_get($this, 'length'),
|
|
95
|
+
'width' => data_get($this, 'width'),
|
|
96
|
+
'height' => data_get($this, 'height'),
|
|
97
|
+
'dimensions_unit' => data_get($this, 'dimensions_unit'),
|
|
98
|
+
'weight' => data_get($this, 'weight'),
|
|
99
|
+
'weight_unit' => data_get($this, 'weight_unit'),
|
|
100
|
+
'declared_value' => data_get($this, 'declared_value'),
|
|
101
|
+
'price' => data_get($this, 'price'),
|
|
102
|
+
'sale_price' => data_get($this, 'sale_price'),
|
|
103
|
+
'sku' => data_get($this, 'sku'),
|
|
104
|
+
'currency' => data_get($this, 'currency'),
|
|
102
105
|
'meta' => $this->meta ?? [],
|
|
103
106
|
'updated_at' => $this->updated_at,
|
|
104
107
|
'created_at' => $this->created_at,
|
|
@@ -50,7 +50,7 @@ class Order extends FleetbaseResource
|
|
|
50
50
|
'pod_method' => $this->pod_method,
|
|
51
51
|
'pod_required' => (bool) data_get($this, 'pod_required', false),
|
|
52
52
|
'dispatched' => (bool) data_get($this, 'dispatched', false),
|
|
53
|
-
'adhoc' => $this
|
|
53
|
+
'adhoc' => (bool) data_get($this, 'adhoc', false),
|
|
54
54
|
'adhoc_distance' => (int) $this->getAdhocDistance(),
|
|
55
55
|
'distance' => (int) $this->distance,
|
|
56
56
|
'time' => (int) $this->time,
|
|
@@ -22,7 +22,7 @@ class ServiceArea extends FleetbaseResource
|
|
|
22
22
|
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
23
23
|
'name' => $this->name,
|
|
24
24
|
'type' => $this->type,
|
|
25
|
-
'
|
|
25
|
+
'center' => $this->location,
|
|
26
26
|
'border' => $this->border,
|
|
27
27
|
'zones' => $this->whenLoaded('zones', Zone::collection($this->zones)),
|
|
28
28
|
'status' => $this->status,
|
|
@@ -42,7 +42,7 @@ class ServiceArea extends FleetbaseResource
|
|
|
42
42
|
'id' => $this->public_id,
|
|
43
43
|
'name' => $this->name,
|
|
44
44
|
'type' => $this->type,
|
|
45
|
-
'
|
|
45
|
+
'center' => $this->location,
|
|
46
46
|
'border' => $this->border,
|
|
47
47
|
'status' => $this->status,
|
|
48
48
|
'updated_at' => $this->updated_at,
|
|
@@ -22,7 +22,6 @@ class Vehicle extends FleetbaseResource
|
|
|
22
22
|
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
23
23
|
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
24
24
|
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
25
|
-
'internal_id' => $this->internal_id,
|
|
26
25
|
'name' => $this->display_name,
|
|
27
26
|
'display_name' => $this->when(Http::isInternalRequest(), $this->display_name),
|
|
28
27
|
'vin' => $this->vin ?? null,
|
|
@@ -59,9 +58,8 @@ class Vehicle extends FleetbaseResource
|
|
|
59
58
|
{
|
|
60
59
|
return [
|
|
61
60
|
'id' => $this->public_id,
|
|
62
|
-
'internal_id' => $this->internal_id,
|
|
63
61
|
'name' => $this->name,
|
|
64
|
-
'vin' => $this->vin
|
|
62
|
+
'vin' => $this->vin,
|
|
65
63
|
'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
|
|
66
64
|
'photo_url' => $this->photoUrl,
|
|
67
65
|
'avatar_url' => $this->avatar_url,
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
4
|
|
|
5
|
-
use Fleetbase\FleetOps\Support\Utils;
|
|
6
5
|
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
6
|
use Fleetbase\Support\Http;
|
|
8
|
-
use Grimzy\LaravelMysqlSpatial\Types\Polygon;
|
|
9
7
|
|
|
10
8
|
class Zone extends FleetbaseResource
|
|
11
9
|
{
|
|
@@ -24,7 +22,7 @@ class Zone extends FleetbaseResource
|
|
|
24
22
|
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
25
23
|
'name' => $this->name,
|
|
26
24
|
'description' => $this->description,
|
|
27
|
-
'
|
|
25
|
+
'center' => $this->location,
|
|
28
26
|
'border' => $this->border,
|
|
29
27
|
'color' => $this->color,
|
|
30
28
|
'stroke_color' => $this->stroke_color,
|
|
@@ -45,7 +43,7 @@ class Zone extends FleetbaseResource
|
|
|
45
43
|
'id' => $this->public_id,
|
|
46
44
|
'name' => $this->name,
|
|
47
45
|
'description' => $this->description,
|
|
48
|
-
'
|
|
46
|
+
'center' => $this->location,
|
|
49
47
|
'border' => $this->border,
|
|
50
48
|
'color' => $this->color,
|
|
51
49
|
'stroke_color' => $this->stroke_color,
|
|
@@ -197,7 +197,7 @@ class Entity extends Model
|
|
|
197
197
|
*/
|
|
198
198
|
public function payload()
|
|
199
199
|
{
|
|
200
|
-
return $this->belongsTo(Payload::class);
|
|
200
|
+
return $this->belongsTo(Payload::class)->without(['entities']);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
/**
|
|
@@ -273,7 +273,7 @@ class Entity extends Model
|
|
|
273
273
|
/**
|
|
274
274
|
* The length the entity belongs to.
|
|
275
275
|
*
|
|
276
|
-
* @var PhpUnitsOfMeasure\PhysicalQuantity\Length
|
|
276
|
+
* @var \PhpUnitsOfMeasure\PhysicalQuantity\Length
|
|
277
277
|
*/
|
|
278
278
|
public function getLengthUnitAttribute()
|
|
279
279
|
{
|
|
@@ -283,7 +283,7 @@ class Entity extends Model
|
|
|
283
283
|
/**
|
|
284
284
|
* The width the entity belongs to.
|
|
285
285
|
*
|
|
286
|
-
* @var PhpUnitsOfMeasure\PhysicalQuantity\Length
|
|
286
|
+
* @var \PhpUnitsOfMeasure\PhysicalQuantity\Length
|
|
287
287
|
*/
|
|
288
288
|
public function getWidthUnitAttribute()
|
|
289
289
|
{
|
|
@@ -350,6 +350,72 @@ class Entity extends Model
|
|
|
350
350
|
return data_get($this, 'trackingNumber.last_status');
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
public function setDestination($destinationKey, Payload $payload, bool $save = true): Entity
|
|
354
|
+
{
|
|
355
|
+
// if waypoint index provided
|
|
356
|
+
if (is_numeric($destinationKey)) {
|
|
357
|
+
$waypoint = $payload->waypoints->values()->get($destinationKey);
|
|
358
|
+
|
|
359
|
+
if ($waypoint) {
|
|
360
|
+
$this->destination_uuid = $waypoint->uuid;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// if explicitly set to pickup
|
|
365
|
+
if ($destinationKey === 'pickup' && $payload->pickup) {
|
|
366
|
+
$this->destination_uuid = $payload->pickup->uuid;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// if explicitly set to dropoff
|
|
370
|
+
if ($destinationKey === 'dropoff' && $payload->dropoff) {
|
|
371
|
+
$this->destination_uuid = $payload->dropoff->uuid;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// if waypoint public_id
|
|
375
|
+
if (Utils::isPublicId($destinationKey)) {
|
|
376
|
+
$waypoint = $payload->waypoints->firstWhere('public_id', $destinationKey);
|
|
377
|
+
|
|
378
|
+
// if no waypoint found from public_id check pickup/dropoff
|
|
379
|
+
if (!$waypoint) {
|
|
380
|
+
$waypoint = collect([$this->pickup, $this->dropoff])->firstWhere('public_id', $destinationKey);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if ($waypoint) {
|
|
384
|
+
$this->destination_uuid = $waypoint->uuid;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// if waypoint uuid
|
|
389
|
+
if (Str::isUuid($destinationKey)) {
|
|
390
|
+
$waypoint = $payload->waypoints->firstWhere('uuid', $destinationKey);
|
|
391
|
+
|
|
392
|
+
// if no waypoint found from uuid check pickup/dropoff
|
|
393
|
+
if (!$waypoint) {
|
|
394
|
+
$waypoint = collect([$payload->pickup, $payload->dropoff])->firstWhere('uuid', $destinationKey);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if ($waypoint) {
|
|
398
|
+
$this->destination_uuid = $waypoint->uuid;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// confirm destination_uuid is indeed a place record
|
|
403
|
+
if (isset($attributes['destination_uuid']) && Place::where('uuid', $attributes['destination_uuid'])->doesntExist()) {
|
|
404
|
+
// search waypoints for search_uuid if any
|
|
405
|
+
$destination = Place::where('meta->search_uuid', $attributes['destination_uuid'])->first();
|
|
406
|
+
|
|
407
|
+
if ($destination instanceof Place) {
|
|
408
|
+
$this->destination_uuid = $destination->uuid;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if ($save) {
|
|
413
|
+
$this->save();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return $this;
|
|
417
|
+
}
|
|
418
|
+
|
|
353
419
|
public static function insertGetUuid($values = [], Payload $payload = null)
|
|
354
420
|
{
|
|
355
421
|
if (is_array($values) && isset($values['uuid'])) {
|
|
@@ -408,4 +474,34 @@ class Entity extends Model
|
|
|
408
474
|
$this->customer_uuid = $model->uuid;
|
|
409
475
|
$this->customer_type = Utils::getMutationType($model);
|
|
410
476
|
}
|
|
477
|
+
|
|
478
|
+
public function getPayload(): ?Payload
|
|
479
|
+
{
|
|
480
|
+
$this->load('payload');
|
|
481
|
+
|
|
482
|
+
if ($this->payload instanceof Payload) {
|
|
483
|
+
return $this->payload;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (Str::isUuid($this->payload_uuid)) {
|
|
487
|
+
return Payload::where('uuid', $this->payload_uuid)->first();
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
public function getTrashedPayload(): ?Payload
|
|
494
|
+
{
|
|
495
|
+
$payload = $this->payload()->withoutGlobalScopes()->first();
|
|
496
|
+
|
|
497
|
+
if ($payload instanceof Payload) {
|
|
498
|
+
return $payload;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (Str::isUuid($this->payload_uuid)) {
|
|
502
|
+
return Payload::where('uuid', $this->payload_uuid)->withoutGlobalScopes()->first();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
411
507
|
}
|