@fleetbase/fleetops-engine 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/components/contact-form-panel.hbs +28 -6
- package/addon/components/driver-form-panel.hbs +10 -0
- package/addon/components/driver-form-panel.js +51 -0
- package/addon/components/driver-panel/details.hbs +1 -5
- package/addon/components/driver-panel.hbs +21 -3
- package/addon/components/fleet-form-panel.hbs +60 -6
- package/addon/components/fleet-listing-panel.hbs +2 -2
- package/addon/components/fleet-panel/details.hbs +1 -1
- package/addon/components/fuel-report-form-panel.hbs +84 -8
- package/addon/components/fuel-report-form-panel.js +6 -0
- package/addon/components/fuel-report-panel/details.hbs +4 -0
- package/addon/components/issue-form-panel.hbs +99 -11
- package/addon/components/issue-form-panel.js +5 -13
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.hbs +1 -0
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.js +3 -0
- package/addon/components/layout/fleet-ops-sidebar.hbs +4 -4
- package/addon/components/layout/fleet-ops-sidebar.js +10 -0
- package/addon/components/live-map-drawer.hbs +1 -1
- package/addon/components/live-map.hbs +1 -1
- package/addon/components/modals/driver-assign-vehicle.hbs +2 -11
- package/addon/components/modals/driver-assign-vendor.hbs +1 -9
- package/addon/components/modals/fuel-report-details.hbs +4 -0
- package/addon/components/order/schedule-card.hbs +32 -4
- package/addon/components/order/schedule-card.js +155 -5
- package/addon/components/place-form-panel.hbs +14 -7
- package/addon/components/place-form-panel.js +71 -0
- package/addon/components/place-panel/details.hbs +9 -19
- package/addon/components/vehicle-form-panel.hbs +67 -7
- package/addon/components/vehicle-form-panel.js +37 -0
- package/addon/components/vehicle-panel/details.hbs +9 -5
- package/addon/components/vehicle-panel.hbs +18 -4
- package/addon/components/vendor-form-panel/create-form.hbs +72 -11
- package/addon/components/vendor-form-panel/edit-form.hbs +1 -1
- package/addon/components/vendor-form-panel.hbs +70 -30
- package/addon/components/vendor-form-panel.js +4 -40
- package/addon/components/vendor-panel/details.hbs +2 -2
- package/addon/components/vendor-panel.hbs +16 -2
- package/addon/controllers/management/contacts/index.js +49 -3
- package/addon/controllers/management/drivers/index.js +7 -0
- package/addon/controllers/management/fleets/index.js +19 -23
- package/addon/controllers/management/fuel-reports/index/new.js +1 -1
- package/addon/controllers/management/fuel-reports/index.js +80 -20
- package/addon/controllers/management/issues/index/new.js +2 -2
- package/addon/controllers/management/issues/index.js +72 -45
- package/addon/controllers/management/places/index.js +65 -18
- package/addon/controllers/management/vehicles/index.js +56 -4
- package/addon/controllers/management/vendors/index.js +70 -8
- package/addon/controllers/operations/orders/index.js +42 -1
- package/addon/controllers/operations/service-rates/index.js +7 -0
- package/addon/routes/management/contacts/index.js +8 -0
- package/addon/routes/management/fleets/index.js +8 -2
- package/addon/routes/management/fuel-reports/index.js +6 -0
- package/addon/routes/management/issues/index.js +9 -1
- package/addon/routes/management/places/index.js +11 -1
- package/addon/routes/management/vehicles/index.js +1 -1
- package/addon/routes/management/vendors/index.js +8 -0
- package/addon/routes/operations/scheduler/index.js +1 -1
- package/addon/templates/management/contacts/index.hbs +1 -0
- package/addon/templates/management/drivers/index.hbs +2 -1
- package/addon/templates/management/fleets/index.hbs +23 -3
- package/addon/templates/management/fuel-reports/index.hbs +1 -0
- package/addon/templates/management/issues/index.hbs +22 -2
- package/addon/templates/management/places/index.hbs +9 -1
- package/addon/templates/management/vehicles/index.hbs +22 -2
- package/addon/templates/management/vendors/index.hbs +22 -2
- package/addon/templates/operations/orders/index.hbs +1 -1
- package/addon/templates/operations/service-rates/index.hbs +11 -3
- package/addon/utils/get-issue-categories.js +30 -0
- package/addon/utils/get-issue-types.js +3 -0
- package/addon/utils/get-vendor-status-options.js +3 -0
- package/addon/utils/get-vendor-type-options.js +41 -0
- package/app/components/layout/fleet-ops-sidebar/fleet-listing.js +1 -0
- package/app/utils/get-issue-categories.js +1 -0
- package/app/utils/get-issue-types.js +1 -0
- package/app/utils/get-vendor-categories.js +1 -0
- package/app/utils/get-vendor-status-options.js +1 -0
- package/app/utils/get-vendor-type-options.js +1 -0
- package/app/utils/get-vendor-types.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +4 -4
- package/server/migrations/2023_04_27_053456_create_contacts_table.php +2 -2
- package/server/migrations/2023_04_27_053456_create_drivers_table.php +5 -5
- package/server/migrations/2023_04_27_053456_create_entities_table.php +5 -5
- package/server/migrations/2023_04_27_053456_create_fleet_drivers_table.php +2 -2
- package/server/migrations/2023_04_27_053456_create_fleets_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_fuel_reports_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_issues_table.php +4 -4
- package/server/migrations/2023_04_27_053456_create_orders_table.php +8 -8
- package/server/migrations/2023_04_27_053456_create_payloads_table.php +5 -5
- package/server/migrations/2023_04_27_053456_create_places_table.php +1 -1
- package/server/migrations/2023_04_27_053456_create_purchase_rates_table.php +4 -4
- package/server/migrations/2023_04_27_053456_create_service_areas_table.php +2 -2
- package/server/migrations/2023_04_27_053456_create_service_quote_items_table.php +1 -1
- package/server/migrations/2023_04_27_053456_create_service_quotes_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_service_rate_fees_table.php +1 -1
- package/server/migrations/2023_04_27_053456_create_service_rate_parcel_fees_table.php +1 -1
- package/server/migrations/2023_04_27_053456_create_service_rates_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_tracking_numbers_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_tracking_statuses_table.php +2 -2
- package/server/migrations/2023_04_27_053456_create_vehicles_table.php +3 -3
- package/server/migrations/2023_04_27_053456_create_vendors_table.php +5 -5
- package/server/migrations/2023_04_27_053456_create_waypoints_table.php +4 -4
- package/server/migrations/2023_04_27_053456_create_zones_table.php +2 -2
- package/server/migrations/2023_11_09_041807_add_status_column_to_fuel_reports_table.php +32 -0
- package/server/migrations/2023_11_15_062814_add_comments_column_and_resolved_at_column_to_vehicle_device_events_table.php +33 -0
- package/server/migrations/2023_11_17_053001_add_category_uuid_to_entities_table.php +33 -0
- package/server/src/Http/Controllers/Api/v1/DriverController.php +2 -2
- package/server/src/Http/Controllers/Api/v1/EntityController.php +2 -0
- package/server/src/Http/Controllers/Api/v1/VehicleController.php +2 -2
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +5 -14
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +1 -3
- package/server/src/Http/Filter/ContactFilter.php +10 -0
- package/server/src/Http/Filter/FleetFilter.php +8 -6
- package/server/src/Http/Filter/FuelReportFilter.php +51 -0
- package/server/src/Http/Filter/IssueFilter.php +61 -5
- package/server/src/Http/Filter/PlaceFilter.php +48 -6
- package/server/src/Http/Filter/VehicleFilter.php +21 -6
- package/server/src/Http/Filter/VendorFilter.php +11 -8
- package/server/src/Http/Middleware/TransformLocationMiddleware.php +1 -1
- package/server/src/Http/Resources/Internal/v1/IntegratedVendorFacilitator.php +17 -18
- package/server/src/Http/Resources/v1/Contact.php +16 -19
- package/server/src/Http/Resources/v1/CurrentJob.php +13 -16
- package/server/src/Http/Resources/v1/Driver.php +59 -57
- package/server/src/Http/Resources/v1/Entity.php +30 -33
- package/server/src/Http/Resources/v1/Fleet.php +19 -17
- package/server/src/Http/Resources/v1/FuelReport.php +16 -14
- package/server/src/Http/Resources/v1/Order.php +1 -1
- package/server/src/Http/Resources/v1/Payload.php +21 -24
- package/server/src/Http/Resources/v1/Place.php +27 -30
- package/server/src/Http/Resources/v1/Proof.php +13 -16
- package/server/src/Http/Resources/v1/PurchaseRate.php +14 -17
- package/server/src/Http/Resources/v1/ServiceArea.php +13 -16
- package/server/src/Http/Resources/v1/ServiceQuote.php +15 -18
- package/server/src/Http/Resources/v1/ServiceRate.php +33 -36
- package/server/src/Http/Resources/v1/ServiceRateFee.php +14 -17
- package/server/src/Http/Resources/v1/ServiceRateParcelFee.php +9 -12
- package/server/src/Http/Resources/v1/TrackingNumber.php +18 -21
- package/server/src/Http/Resources/v1/TrackingStatus.php +18 -21
- package/server/src/Http/Resources/v1/Vehicle.php +31 -34
- package/server/src/Http/Resources/v1/VehicleDevice.php +23 -25
- package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +38 -32
- package/server/src/Http/Resources/v1/Vendor.php +31 -26
- package/server/src/Http/Resources/v1/Zone.php +14 -17
- package/server/src/Models/Driver.php +23 -1
- package/server/src/Models/Entity.php +18 -23
- package/server/src/Models/FuelReport.php +1 -0
- package/server/src/Models/IntegratedVendor.php +6 -1
- package/server/src/Models/Order.php +2 -2
- package/server/src/Models/Place.php +2 -2
- package/server/src/Models/Vehicle.php +4 -2
- package/server/src/Models/VehicleDeviceEvent.php +1 -0
- package/server/src/Models/Vendor.php +1 -1
- package/server/src/Observers/DriverObserver.php +15 -0
|
@@ -14,14 +14,7 @@ class VendorFilter extends Filter
|
|
|
14
14
|
|
|
15
15
|
public function query(?string $searchQuery)
|
|
16
16
|
{
|
|
17
|
-
$this->builder->
|
|
18
|
-
$query->orWhereHas(
|
|
19
|
-
'user',
|
|
20
|
-
function ($query) use ($searchQuery) {
|
|
21
|
-
$query->searchWhere(['name', 'email', 'phone', 'address'], $searchQuery);
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
});
|
|
17
|
+
$this->builder->search($searchQuery);
|
|
25
18
|
}
|
|
26
19
|
|
|
27
20
|
public function internalId(?string $internalId)
|
|
@@ -49,6 +42,11 @@ class VendorFilter extends Filter
|
|
|
49
42
|
$this->builder->searchWhere('email', $email);
|
|
50
43
|
}
|
|
51
44
|
|
|
45
|
+
public function websiteUrl(?string $websiteUrl)
|
|
46
|
+
{
|
|
47
|
+
$this->builder->searchWhere('website_url', $websiteUrl);
|
|
48
|
+
}
|
|
49
|
+
|
|
52
50
|
public function country(?string $country)
|
|
53
51
|
{
|
|
54
52
|
$this->builder->searchWhere('country', $country);
|
|
@@ -59,6 +57,11 @@ class VendorFilter extends Filter
|
|
|
59
57
|
$this->builder->searchWhere('status', $status);
|
|
60
58
|
}
|
|
61
59
|
|
|
60
|
+
public function address(?string $address)
|
|
61
|
+
{
|
|
62
|
+
$this->builder->searchWhere('place_uuid', $address);
|
|
63
|
+
}
|
|
64
|
+
|
|
62
65
|
public function createdAt($createdAt)
|
|
63
66
|
{
|
|
64
67
|
$createdAt = Utils::dateRange($createdAt);
|
|
@@ -35,7 +35,7 @@ class TransformLocationMiddleware
|
|
|
35
35
|
{
|
|
36
36
|
foreach ($data as $key => $value) {
|
|
37
37
|
if (is_array($value)) {
|
|
38
|
-
// If the value is
|
|
38
|
+
// If the value is a valid coordinates type, recursively transform it
|
|
39
39
|
$data[$key] = $this->transformNestedLocation($value);
|
|
40
40
|
} elseif ($key === 'location' && $value === null) {
|
|
41
41
|
// Transform the 'location' property if it's null
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Http\Resources\Internal\v1;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
6
7
|
|
|
7
8
|
class IntegratedVendorFacilitator extends FleetbaseResource
|
|
8
9
|
{
|
|
@@ -15,23 +16,21 @@ class IntegratedVendorFacilitator extends FleetbaseResource
|
|
|
15
16
|
*/
|
|
16
17
|
public function toArray($request)
|
|
17
18
|
{
|
|
18
|
-
return
|
|
19
|
-
$this->
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
]
|
|
35
|
-
);
|
|
19
|
+
return [
|
|
20
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
21
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
22
|
+
'public_id' => $this->public_id,
|
|
23
|
+
'uuid' => $this->uuid,
|
|
24
|
+
'name' => $this->name,
|
|
25
|
+
'photo_url' => $this->photo_url,
|
|
26
|
+
'provider' => $this->provider,
|
|
27
|
+
'options' => $this->options,
|
|
28
|
+
'sandbox' => $this->sandbox,
|
|
29
|
+
'facilitator_type' => $this->type,
|
|
30
|
+
'type' => 'facilitator',
|
|
31
|
+
'status' => $this->status,
|
|
32
|
+
'updated_at' => $this->updated_at,
|
|
33
|
+
'created_at' => $this->created_at,
|
|
34
|
+
];
|
|
36
35
|
}
|
|
37
36
|
}
|
|
@@ -16,25 +16,22 @@ class Contact extends FleetbaseResource
|
|
|
16
16
|
*/
|
|
17
17
|
public function toArray($request)
|
|
18
18
|
{
|
|
19
|
-
return
|
|
20
|
-
$this->
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'created_at' => $this->created_at,
|
|
36
|
-
]
|
|
37
|
-
);
|
|
19
|
+
return [
|
|
20
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
21
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
22
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
23
|
+
'internal_id' => $this->internal_id,
|
|
24
|
+
'name' => $this->name,
|
|
25
|
+
'title' => $this->title ?? null,
|
|
26
|
+
'email' => $this->email ?? null,
|
|
27
|
+
'phone' => $this->phone ?? null,
|
|
28
|
+
'photo_url' => $this->photo_url ?? null,
|
|
29
|
+
'type' => $this->type ?? null,
|
|
30
|
+
'meta' => $this->meta ?? [],
|
|
31
|
+
'slug' => $this->slug ?? null,
|
|
32
|
+
'updated_at' => $this->updated_at,
|
|
33
|
+
'created_at' => $this->created_at,
|
|
34
|
+
];
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
/**
|
|
@@ -16,21 +16,18 @@ class CurrentJob extends FleetbaseResource
|
|
|
16
16
|
*/
|
|
17
17
|
public function toArray($request)
|
|
18
18
|
{
|
|
19
|
-
return
|
|
20
|
-
$this->
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'created_at' => $this->created_at,
|
|
33
|
-
]
|
|
34
|
-
);
|
|
19
|
+
return [
|
|
20
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
21
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
22
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
23
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
24
|
+
'internal_id' => $this->internal_id,
|
|
25
|
+
'payload' => $this->when(Http::isInternalRequest(), new Payload($this->payload)),
|
|
26
|
+
'type' => $this->type,
|
|
27
|
+
'status' => $this->status,
|
|
28
|
+
'meta' => $this->meta ?? [],
|
|
29
|
+
'updated_at' => $this->updated_at,
|
|
30
|
+
'created_at' => $this->created_at,
|
|
31
|
+
];
|
|
35
32
|
}
|
|
36
33
|
}
|
|
@@ -18,42 +18,44 @@ class Driver extends FleetbaseResource
|
|
|
18
18
|
*/
|
|
19
19
|
public function toArray($request)
|
|
20
20
|
{
|
|
21
|
-
return
|
|
22
|
-
$this->
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
21
|
+
return [
|
|
22
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
23
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
24
|
+
'user_uuid' => $this->when(Http::isInternalRequest(), $this->user_uuid),
|
|
25
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
26
|
+
'vehicle_uuid' => $this->when(Http::isInternalRequest(), $this->vehicle_uuid),
|
|
27
|
+
'vendor_uuid' => $this->when(Http::isInternalRequest(), $this->vendor_uuid),
|
|
28
|
+
'current_job_uuid' => $this->when(Http::isInternalRequest(), $this->current_job_uuid),
|
|
29
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
30
|
+
'internal_id' => $this->internal_id,
|
|
31
|
+
'name' => $this->name,
|
|
32
|
+
'email' => $this->email ?? null,
|
|
33
|
+
'phone' => $this->phone ?? null,
|
|
34
|
+
'drivers_license_number' => $this->drivers_license_number ?? null,
|
|
35
|
+
'photo_url' => $this->photo_url ?? null,
|
|
36
|
+
'vehicle_name' => $this->when(Http::isInternalRequest(), $this->vehicle_name),
|
|
37
|
+
'vehicle_avatar' => $this->when(Http::isInternalRequest(), $this->vehicle_avatar),
|
|
38
|
+
'vendor_name' => $this->when(Http::isInternalRequest(), $this->vendor_name),
|
|
39
|
+
'vehicle' => $this->whenLoaded('vehicle', new VehicleWithoutDriver($this->vehicle)),
|
|
40
|
+
'current_job' => $this->whenLoaded('currentJob', new CurrentJob($this->currentJob)),
|
|
41
|
+
'current_job_id' => $this->when(Http::isInternalRequest(), data_get($this, 'currentJob.public_id')),
|
|
42
|
+
'jobs' => $this->whenLoaded('jobs', CurrentJob::collection($this->jobs()->without(['driverAssigned'])->get())),
|
|
43
|
+
'vendor' => $this->whenLoaded('vendor', new Vendor($this->vendor)),
|
|
44
|
+
'fleets' => $this->whenLoaded('fleets', Fleet::collection($this->fleets()->without('drivers')->get())),
|
|
45
|
+
'location' => data_get($this, 'location', new Point(0, 0)),
|
|
46
|
+
'heading' => (int) data_get($this, 'heading', 0),
|
|
47
|
+
'altitude' => (int) data_get($this, 'altitude', 0),
|
|
48
|
+
'speed' => (int) data_get($this, 'speed', 0),
|
|
49
|
+
'country' => data_get($this, 'country'),
|
|
50
|
+
'currency' => data_get($this, 'currency', Utils::getCurrenyFromCountryCode($this->country)),
|
|
51
|
+
'city' => data_get($this, 'city', Utils::getCapitalCityFromCountryCode($this->country)),
|
|
52
|
+
'online' => data_get($this, 'online', false),
|
|
53
|
+
'status' => $this->status,
|
|
54
|
+
'token' => data_get($this, 'token'),
|
|
55
|
+
'meta' => $this->meta,
|
|
56
|
+
'updated_at' => $this->updated_at,
|
|
57
|
+
'created_at' => $this->created_at,
|
|
58
|
+
];
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
/**
|
|
@@ -64,27 +66,27 @@ class Driver extends FleetbaseResource
|
|
|
64
66
|
public function toWebhookPayload()
|
|
65
67
|
{
|
|
66
68
|
return [
|
|
67
|
-
'id'
|
|
68
|
-
'internal_id'
|
|
69
|
-
'name'
|
|
70
|
-
'email'
|
|
71
|
-
'phone'
|
|
72
|
-
'photo_url'
|
|
73
|
-
'vehicle'
|
|
74
|
-
'current_job'
|
|
75
|
-
'vendor'
|
|
76
|
-
'location'
|
|
77
|
-
'heading'
|
|
78
|
-
'altitude'
|
|
79
|
-
'speed'
|
|
80
|
-
'country'
|
|
81
|
-
'currency'
|
|
82
|
-
'city'
|
|
83
|
-
'online'
|
|
84
|
-
'status'
|
|
85
|
-
'meta'
|
|
86
|
-
'updated_at'
|
|
87
|
-
'created_at'
|
|
69
|
+
'id' => $this->public_id,
|
|
70
|
+
'internal_id' => $this->internal_id,
|
|
71
|
+
'name' => $this->name,
|
|
72
|
+
'email' => $this->email,
|
|
73
|
+
'phone' => $this->phone,
|
|
74
|
+
'photo_url' => $this->photo_url,
|
|
75
|
+
'vehicle' => data_get($this, 'vehicle.public_id'),
|
|
76
|
+
'current_job' => data_get($this, 'currentJob.public_id'),
|
|
77
|
+
'vendor' => data_get($this, 'vendor.public_id'),
|
|
78
|
+
'location' => data_get($this, 'location', new Point(0, 0)),
|
|
79
|
+
'heading' => (int) data_get($this, 'heading', 0),
|
|
80
|
+
'altitude' => (int) data_get($this, 'altitude', 0),
|
|
81
|
+
'speed' => (int) data_get($this, 'speed', 0),
|
|
82
|
+
'country' => data_get($this, 'country'),
|
|
83
|
+
'currency' => data_get($this, 'currency', Utils::getCurrenyFromCountryCode($this->country)),
|
|
84
|
+
'city' => data_get($this, 'city', Utils::getCapitalCityFromCountryCode($this->country)),
|
|
85
|
+
'online' => data_get($this, 'online', false),
|
|
86
|
+
'status' => $this->status,
|
|
87
|
+
'meta' => $this->meta,
|
|
88
|
+
'updated_at' => $this->updated_at,
|
|
89
|
+
'created_at' => $this->created_at,
|
|
88
90
|
];
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -17,39 +17,36 @@ class Entity extends FleetbaseResource
|
|
|
17
17
|
*/
|
|
18
18
|
public function toArray($request)
|
|
19
19
|
{
|
|
20
|
-
return
|
|
21
|
-
$this->
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
'created_at' => $this->created_at,
|
|
51
|
-
]
|
|
52
|
-
);
|
|
20
|
+
return [
|
|
21
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
22
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
23
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
24
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
25
|
+
'customer_uuid' => $this->when(Http::isInternalRequest(), $this->customer_uuid),
|
|
26
|
+
'customer_type' => $this->when(Http::isInternalRequest(), $this->customer_type),
|
|
27
|
+
'internal_id' => $this->internal_id,
|
|
28
|
+
'name' => $this->name,
|
|
29
|
+
'type' => $this->type ?? null,
|
|
30
|
+
'destination' => $this->when(Http::isPublicRequest(), data_get($this, 'destination.public_id'), null),
|
|
31
|
+
'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
|
|
32
|
+
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
33
|
+
'description' => $this->description ?? null,
|
|
34
|
+
'photo_url' => $this->photo_url ?? null,
|
|
35
|
+
'length' => $this->length ?? null,
|
|
36
|
+
'width' => $this->width ?? null,
|
|
37
|
+
'height' => $this->height ?? null,
|
|
38
|
+
'dimensions_unit' => $this->dimensions_unit ?? null,
|
|
39
|
+
'weight' => $this->weight ?? null,
|
|
40
|
+
'weight_unit' => $this->weight_unit ?? null,
|
|
41
|
+
'declared_value' => $this->declared_value ?? null,
|
|
42
|
+
'price' => $this->price ?? null,
|
|
43
|
+
'sale_price' => $this->sale_price ?? null,
|
|
44
|
+
'sku' => $this->sku ?? null,
|
|
45
|
+
'currency' => $this->currency ?? null,
|
|
46
|
+
'meta' => $this->meta ?? [],
|
|
47
|
+
'updated_at' => $this->updated_at,
|
|
48
|
+
'created_at' => $this->created_at,
|
|
49
|
+
];
|
|
53
50
|
}
|
|
54
51
|
|
|
55
52
|
/**
|
|
@@ -17,23 +17,25 @@ class Fleet extends FleetbaseResource
|
|
|
17
17
|
public function toArray($request)
|
|
18
18
|
{
|
|
19
19
|
return [
|
|
20
|
-
'id'
|
|
21
|
-
'uuid'
|
|
22
|
-
'public_id'
|
|
23
|
-
'name'
|
|
24
|
-
'task'
|
|
25
|
-
'status'
|
|
26
|
-
'drivers_count'
|
|
27
|
-
'drivers_online_count'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
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
|
+
'parent_fleet' => $this->whenLoaded('parentFleet', new ParentFleet($this->parentFleet)),
|
|
34
|
+
'subfleets' => $this->whenLoaded('subFleets', SubFleet::collection($this->subFleets)),
|
|
35
|
+
'drivers' => $this->whenLoaded('drivers', Driver::collection($this->drivers()->without(['driverAssigned'])->with(Http::isInternalRequest() ? ['jobs'] : [])->get())),
|
|
36
|
+
'vehicles' => $this->whenLoaded('vehicles', Vehicle::collection($this->vehicles)),
|
|
37
|
+
'updated_at' => $this->updated_at,
|
|
38
|
+
'created_at' => $this->created_at,
|
|
37
39
|
];
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -36,6 +36,7 @@ class FuelReport extends FleetbaseResource
|
|
|
36
36
|
'volume' => $this->volume,
|
|
37
37
|
'metric_unit' => $this->metric_unit,
|
|
38
38
|
'type' => $this->type,
|
|
39
|
+
'status' => $this->status,
|
|
39
40
|
'location' => $this->location ?? new Point(0, 0),
|
|
40
41
|
'updated_at' => $this->updated_at,
|
|
41
42
|
'created_at' => $this->created_at,
|
|
@@ -50,20 +51,21 @@ class FuelReport extends FleetbaseResource
|
|
|
50
51
|
public function toWebhookPayload()
|
|
51
52
|
{
|
|
52
53
|
return [
|
|
53
|
-
'id'
|
|
54
|
-
'reporter'
|
|
55
|
-
'driver'
|
|
56
|
-
'vehicle'
|
|
57
|
-
'
|
|
58
|
-
'odometer'
|
|
59
|
-
'amount'
|
|
60
|
-
'currency'
|
|
61
|
-
'volume'
|
|
62
|
-
'metric_unit'
|
|
63
|
-
'type'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
'
|
|
54
|
+
'id' => $this->public_id,
|
|
55
|
+
'reporter' => data_get($this, 'reportedBy.public_id'),
|
|
56
|
+
'driver' => data_get($this, 'driver.public_id'),
|
|
57
|
+
'vehicle' => data_get($this, 'vehicle.public_id'),
|
|
58
|
+
'report_name' => $this->report,
|
|
59
|
+
'odometer' => $this->odometer,
|
|
60
|
+
'amount' => $this->amount,
|
|
61
|
+
'currency' => $this->currency,
|
|
62
|
+
'volume' => $this->volume,
|
|
63
|
+
'metric_unit' => $this->metric_unit,
|
|
64
|
+
'type' => $this->type,
|
|
65
|
+
'status' => $this->status,
|
|
66
|
+
'location' => $this->location ?? new Point(0, 0),
|
|
67
|
+
'updated_at' => $this->updated_at,
|
|
68
|
+
'created_at' => $this->created_at,
|
|
67
69
|
];
|
|
68
70
|
}
|
|
69
71
|
}
|
|
@@ -40,7 +40,7 @@ class Order extends FleetbaseResource
|
|
|
40
40
|
'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
|
|
41
41
|
'payload' => new Payload($this->payload),
|
|
42
42
|
'facilitator' => $this->setFacilitatorType(Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid)),
|
|
43
|
-
'driver_assigned' => new Driver($this->driverAssigned()->without(['jobs', 'currentJob'
|
|
43
|
+
'driver_assigned' => new Driver($this->driverAssigned()->without(['jobs', 'currentJob'])->first()),
|
|
44
44
|
'tracking_number' => new TrackingNumber($this->trackingNumber),
|
|
45
45
|
'tracking_statuses' => $this->whenLoaded('trackingStatuses', TrackingStatus::collection($this->trackingStatuses)),
|
|
46
46
|
'purchase_rate' => new PurchaseRate($this->purchaseRate),
|
|
@@ -17,30 +17,27 @@ class Payload extends FleetbaseResource
|
|
|
17
17
|
*/
|
|
18
18
|
public function toArray($request)
|
|
19
19
|
{
|
|
20
|
-
return
|
|
21
|
-
$this->
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'created_at' => $this->created_at,
|
|
42
|
-
]
|
|
43
|
-
);
|
|
20
|
+
return [
|
|
21
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
22
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
23
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
24
|
+
'current_waypoint_uuid' => $this->when(Http::isInternalRequest(), $this->current_waypoint_uuid),
|
|
25
|
+
'pickup_uuid' => $this->when(Http::isInternalRequest(), $this->pickup_uuid),
|
|
26
|
+
'dropoff_uuid' => $this->when(Http::isInternalRequest(), $this->dropoff_uuid),
|
|
27
|
+
'return_uuid' => $this->when(Http::isInternalRequest(), $this->return_uuid),
|
|
28
|
+
'current_waypoint' => $this->when(!Http::isInternalRequest() && $this->currentWaypoint, data_get($this, 'currentWaypoint.public_id'), null),
|
|
29
|
+
'pickup' => new Place($this->pickup),
|
|
30
|
+
'dropoff' => new Place($this->dropoff),
|
|
31
|
+
'return' => new Place($this->return),
|
|
32
|
+
'waypoints' => $this->waypoints($this->waypoints),
|
|
33
|
+
'entities' => Entity::collection($this->entities ?? []),
|
|
34
|
+
'cod_amount' => $this->cod_amount ?? null,
|
|
35
|
+
'cod_currency' => $this->cod_currency ?? null,
|
|
36
|
+
'cod_payment_method' => $this->cod_payment_method ?? null,
|
|
37
|
+
'meta' => $this->meta ?? [],
|
|
38
|
+
'updated_at' => $this->updated_at,
|
|
39
|
+
'created_at' => $this->created_at,
|
|
40
|
+
];
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
/**
|