@fleetbase/fleetops-engine 0.4.7 → 0.4.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.
- package/addon/services/location.js +10 -8
- package/composer.json +2 -2
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/src/Casts/Point.php +0 -2
- package/server/src/Exceptions/IntegratedVendorException.php +2 -2
- package/server/src/Flow/Activity.php +4 -3
- package/server/src/Flow/Config.php +4 -4
- package/server/src/Flow/Logic.php +4 -4
- package/server/src/Http/Controllers/Api/v1/DriverController.php +14 -17
- package/server/src/Http/Controllers/Api/v1/OrderController.php +5 -5
- package/server/src/Http/Controllers/Api/v1/TrackingNumberController.php +1 -1
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +7 -5
- package/server/src/Http/Controllers/Internal/v1/FleetOpsLookupController.php +1 -1
- package/server/src/Http/Controllers/Internal/v1/GeocoderController.php +2 -2
- package/server/src/Http/Controllers/Internal/v1/MetricsController.php +0 -1
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +4 -4
- package/server/src/Http/Resources/v1/Order.php +1 -1
- package/server/src/Http/Resources/v1/ServiceQuoteItem.php +6 -6
- package/server/src/Imports/OrdersImport.php +1 -1
- package/server/src/Integrations/Lalamove/Lalamove.php +5 -5
- package/server/src/Jobs/SimulateDrivingRoute.php +2 -2
- package/server/src/Jobs/SimulateWaypointReached.php +2 -2
- package/server/src/Listeners/HandleOrderDispatchFailed.php +1 -1
- package/server/src/Listeners/HandleOrderDriverAssigned.php +2 -2
- package/server/src/Models/Driver.php +2 -2
- package/server/src/Models/Entity.php +3 -3
- package/server/src/Models/Order.php +4 -4
- package/server/src/Models/Payload.php +8 -8
- package/server/src/Models/Place.php +1 -1
- package/server/src/Models/ServiceArea.php +9 -9
- package/server/src/Models/ServiceRate.php +2 -2
- package/server/src/Models/TrackingNumber.php +2 -2
- package/server/src/Models/TrackingStatus.php +1 -1
- package/server/src/Models/Vehicle.php +3 -3
- package/server/src/Models/Waypoint.php +1 -1
- package/server/src/Models/Zone.php +4 -4
- package/server/src/Notifications/OrderAssigned.php +1 -1
- package/server/src/Notifications/OrderCanceled.php +1 -1
- package/server/src/Notifications/OrderDispatchFailed.php +1 -1
- package/server/src/Notifications/OrderDispatched.php +1 -1
- package/server/src/Notifications/OrderSplit.php +1 -1
- package/server/src/Support/Flow.php +6 -6
- package/server/src/Support/Geocoding.php +1 -1
- package/server/src/Support/IntegratedVendors.php +1 -1
- package/server/src/Support/Metrics.php +15 -15
- package/server/src/routes.php +3 -3
|
@@ -93,14 +93,16 @@ export default class LocationService extends Service {
|
|
|
93
93
|
|
|
94
94
|
if (isArray(coordinates)) {
|
|
95
95
|
const validCoordinates = coordinates.filter((point) => point.coordinates[0] !== 0);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
if (validCoordinates) {
|
|
97
|
+
const [longitude, latitude] = getWithDefault(validCoordinates, '0.coordinates', [0, 0]);
|
|
98
|
+
const userCoordinates = {
|
|
99
|
+
latitude,
|
|
100
|
+
longitude,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
this.updateLocation(userCoordinates);
|
|
104
|
+
return userCoordinates;
|
|
105
|
+
}
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
return this.getUserLocationFromWhois();
|
package/composer.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetbase/fleetops-api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "Fleet & Transport Management Extension for Fleetbase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fleetbase-extension",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"require": {
|
|
24
24
|
"php": "^8.0",
|
|
25
|
-
"fleetbase/core-api": "^1.4.
|
|
25
|
+
"fleetbase/core-api": "^1.4.3",
|
|
26
26
|
"barryvdh/laravel-dompdf": "^2.0",
|
|
27
27
|
"brick/geo": "0.7.2",
|
|
28
28
|
"cknow/laravel-money": "^7.1",
|
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@ class IntegratedVendorException extends \Exception implements Responsable
|
|
|
32
32
|
* @param int $code the exception code
|
|
33
33
|
* @param \Throwable|null $previous the previous throwable used for the exception chaining
|
|
34
34
|
*/
|
|
35
|
-
public function __construct(string $message = '', IntegratedVendor $integratedVendor = null, string $triggerMethod = null, int $code = 400,
|
|
35
|
+
public function __construct(string $message = '', ?IntegratedVendor $integratedVendor = null, ?string $triggerMethod = null, int $code = 400, ?\Throwable $previous = null)
|
|
36
36
|
{
|
|
37
37
|
parent::__construct($message, $code, $previous);
|
|
38
38
|
$this->integratedVendor = $integratedVendor;
|
|
@@ -44,7 +44,7 @@ class IntegratedVendorException extends \Exception implements Responsable
|
|
|
44
44
|
*
|
|
45
45
|
* @param \Illuminate\Http\Request $request
|
|
46
46
|
*
|
|
47
|
-
* @return
|
|
47
|
+
* @return JsonResponse
|
|
48
48
|
*/
|
|
49
49
|
public function toResponse($request)
|
|
50
50
|
{
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
<?php
|
|
1
|
+
<?php
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Flow;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Models\Model;
|
|
6
6
|
|
|
7
|
-
class Activity
|
|
7
|
+
class Activity
|
|
8
|
+
{
|
|
8
9
|
protected string $status;
|
|
9
10
|
protected string $code;
|
|
10
11
|
protected string $details;
|
|
11
12
|
protected Model $owner;
|
|
12
|
-
}
|
|
13
|
+
}
|
|
@@ -354,7 +354,7 @@ class DriverController extends Controller
|
|
|
354
354
|
/**
|
|
355
355
|
* Authenticates customer using login credentials and returns with auth token.
|
|
356
356
|
*
|
|
357
|
-
* @return
|
|
357
|
+
* @return DriverResource
|
|
358
358
|
*/
|
|
359
359
|
public function login(Request $request)
|
|
360
360
|
{
|
|
@@ -418,9 +418,11 @@ class DriverController extends Controller
|
|
|
418
418
|
|
|
419
419
|
// generate verification token
|
|
420
420
|
try {
|
|
421
|
-
VerificationCode::generateSmsVerificationFor($user, 'driver_login',
|
|
422
|
-
|
|
423
|
-
|
|
421
|
+
VerificationCode::generateSmsVerificationFor($user, 'driver_login', [
|
|
422
|
+
'messageCallback' => function ($verification) use ($company) {
|
|
423
|
+
return 'Your ' . data_get($company, 'name', config('app.name')) . ' verification code is ' . $verification->code;
|
|
424
|
+
},
|
|
425
|
+
]);
|
|
424
426
|
} catch (\Throwable $e) {
|
|
425
427
|
if (app()->bound('sentry')) {
|
|
426
428
|
app('sentry')->captureException($e);
|
|
@@ -435,7 +437,7 @@ class DriverController extends Controller
|
|
|
435
437
|
/**
|
|
436
438
|
* Verifys SMS code and sends auth token with customer resource.
|
|
437
439
|
*
|
|
438
|
-
* @return
|
|
440
|
+
* @return DriverResource
|
|
439
441
|
*/
|
|
440
442
|
public function verifyCode(Request $request)
|
|
441
443
|
{
|
|
@@ -489,11 +491,9 @@ class DriverController extends Controller
|
|
|
489
491
|
}
|
|
490
492
|
|
|
491
493
|
/**
|
|
492
|
-
* Gets the current organization/company for the driver
|
|
494
|
+
* Gets the current organization/company for the driver.
|
|
493
495
|
*
|
|
494
|
-
* @
|
|
495
|
-
* @param \Illuminate\Http\Request $request
|
|
496
|
-
* @return \Fleetbase\Http\Resources\Organization
|
|
496
|
+
* @return Organization
|
|
497
497
|
*/
|
|
498
498
|
public function currentOrganization(string $id, Request $request)
|
|
499
499
|
{
|
|
@@ -521,7 +521,7 @@ class DriverController extends Controller
|
|
|
521
521
|
/**
|
|
522
522
|
* List organizations that driver is apart of.
|
|
523
523
|
*
|
|
524
|
-
* @return
|
|
524
|
+
* @return Organization
|
|
525
525
|
*/
|
|
526
526
|
public function listOrganizations(string $id, Request $request)
|
|
527
527
|
{
|
|
@@ -546,7 +546,7 @@ class DriverController extends Controller
|
|
|
546
546
|
/**
|
|
547
547
|
* Allow driver to switch organization.
|
|
548
548
|
*
|
|
549
|
-
* @return
|
|
549
|
+
* @return Organization
|
|
550
550
|
*/
|
|
551
551
|
public function switchOrganization(string $id, SwitchOrganizationRequest $request)
|
|
552
552
|
{
|
|
@@ -604,7 +604,7 @@ class DriverController extends Controller
|
|
|
604
604
|
$order = $request->input('order');
|
|
605
605
|
|
|
606
606
|
try {
|
|
607
|
-
/** @var
|
|
607
|
+
/** @var Driver $driver */
|
|
608
608
|
$driver = Driver::findRecordOrFail($id, ['user']);
|
|
609
609
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) {
|
|
610
610
|
return response()->json(
|
|
@@ -617,7 +617,7 @@ class DriverController extends Controller
|
|
|
617
617
|
|
|
618
618
|
if ($order) {
|
|
619
619
|
try {
|
|
620
|
-
/** @var
|
|
620
|
+
/** @var Order $order */
|
|
621
621
|
$order = Order::findRecordOrFail($order, ['payload']);
|
|
622
622
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) {
|
|
623
623
|
return response()->json(
|
|
@@ -720,9 +720,6 @@ class DriverController extends Controller
|
|
|
720
720
|
|
|
721
721
|
/**
|
|
722
722
|
* Get the drivers current company using their user account.
|
|
723
|
-
*
|
|
724
|
-
* @param \Fleetbase\Models\User $user
|
|
725
|
-
* @return \Fleetbase\Models\Company|null
|
|
726
723
|
*/
|
|
727
724
|
private static function getDriverCompanyFromUser(User $user): ?Company
|
|
728
725
|
{
|
|
@@ -747,7 +744,7 @@ class DriverController extends Controller
|
|
|
747
744
|
/**
|
|
748
745
|
* Patches phone number with international code.
|
|
749
746
|
*/
|
|
750
|
-
private static function phone(string $phone = null): string
|
|
747
|
+
private static function phone(?string $phone = null): string
|
|
751
748
|
{
|
|
752
749
|
if ($phone === null) {
|
|
753
750
|
$phone = request()->input('phone');
|
|
@@ -423,7 +423,7 @@ class OrderController extends Controller
|
|
|
423
423
|
{
|
|
424
424
|
$results = Order::queryWithRequest($request, function (&$query, $request) {
|
|
425
425
|
$query->where('company_uuid', session('company'));
|
|
426
|
-
|
|
426
|
+
|
|
427
427
|
if ($request->has('payload')) {
|
|
428
428
|
$query->whereHas('payload', function ($q) use ($request) {
|
|
429
429
|
$q->where('public_id', $request->input('payload'));
|
|
@@ -691,7 +691,7 @@ class OrderController extends Controller
|
|
|
691
691
|
/**
|
|
692
692
|
* Schedules an order using date and time.
|
|
693
693
|
*
|
|
694
|
-
* @param
|
|
694
|
+
* @param ScheduleOrderRequest
|
|
695
695
|
*
|
|
696
696
|
* @return \Fleetbase\Http\Resources\v1\Order
|
|
697
697
|
*/
|
|
@@ -835,7 +835,7 @@ class OrderController extends Controller
|
|
|
835
835
|
|
|
836
836
|
// if instance of order is passed directly to this method
|
|
837
837
|
if ($id instanceof Order) {
|
|
838
|
-
/** @var
|
|
838
|
+
/** @var Order $order */
|
|
839
839
|
$order = $id;
|
|
840
840
|
}
|
|
841
841
|
|
|
@@ -1112,7 +1112,7 @@ class OrderController extends Controller
|
|
|
1112
1112
|
*
|
|
1113
1113
|
* @return void
|
|
1114
1114
|
*/
|
|
1115
|
-
public function captureQrScan(string $id, string $subjectId = null, Request $request)
|
|
1115
|
+
public function captureQrScan(string $id, ?string $subjectId = null, Request $request)
|
|
1116
1116
|
{
|
|
1117
1117
|
$code = $request->input('code');
|
|
1118
1118
|
$data = $request->input('data', []);
|
|
@@ -1183,7 +1183,7 @@ class OrderController extends Controller
|
|
|
1183
1183
|
*
|
|
1184
1184
|
* @return void
|
|
1185
1185
|
*/
|
|
1186
|
-
public function captureSignature(string $id, string $subjectId = null, Request $request)
|
|
1186
|
+
public function captureSignature(string $id, ?string $subjectId = null, Request $request)
|
|
1187
1187
|
{
|
|
1188
1188
|
$disk = $request->input('disk', config('filesystems.default'));
|
|
1189
1189
|
$bucket = $request->input('bucket', config('filesystems.disks.' . $disk . '.bucket', config('filesystems.disks.s3.bucket')));
|
|
@@ -115,7 +115,7 @@ class TrackingNumberController extends Controller
|
|
|
115
115
|
/**
|
|
116
116
|
* Take the uuid value of an entity QR code and return the object.
|
|
117
117
|
*
|
|
118
|
-
* @param
|
|
118
|
+
* @param Request $request
|
|
119
119
|
*
|
|
120
120
|
* @return \Illuminate\Http\Response
|
|
121
121
|
*/
|
|
@@ -116,7 +116,7 @@ class DriverController extends FleetOpsController
|
|
|
116
116
|
CompanyUser::create([
|
|
117
117
|
'user_uuid' => $existingUser->uuid,
|
|
118
118
|
'company_uuid' => $company->uuid,
|
|
119
|
-
'status' => $isOrganizationMember ? 'active' : 'pending'
|
|
119
|
+
'status' => $isOrganizationMember ? 'active' : 'pending',
|
|
120
120
|
]);
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -397,9 +397,11 @@ class DriverController extends FleetOpsController
|
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
// Generate verification token
|
|
400
|
-
VerificationCode::generateSmsVerificationFor($user, 'driver_login',
|
|
401
|
-
|
|
402
|
-
|
|
400
|
+
VerificationCode::generateSmsVerificationFor($user, 'driver_login', [
|
|
401
|
+
'messageCallback' => function ($verification) {
|
|
402
|
+
return 'Your ' . config('app.name') . ' verification code is ' . $verification->code;
|
|
403
|
+
},
|
|
404
|
+
]);
|
|
403
405
|
|
|
404
406
|
return response()->json(['status' => 'OK']);
|
|
405
407
|
}
|
|
@@ -453,7 +455,7 @@ class DriverController extends FleetOpsController
|
|
|
453
455
|
/**
|
|
454
456
|
* Patches phone number with international code.
|
|
455
457
|
*/
|
|
456
|
-
public static function phone(string $phone = null): string
|
|
458
|
+
public static function phone(?string $phone = null): string
|
|
457
459
|
{
|
|
458
460
|
if ($phone === null) {
|
|
459
461
|
$phone = request()->input('phone');
|
|
@@ -16,7 +16,7 @@ class FleetOpsLookupController extends Controller
|
|
|
16
16
|
/**
|
|
17
17
|
* Returns a collection of polymorphic resources as JSON.
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
19
|
+
* @param Request $request the HTTP request object
|
|
20
20
|
*
|
|
21
21
|
* @return \Illuminate\Http\Response the JSON response with the polymorphic resources
|
|
22
22
|
*/
|
|
@@ -13,7 +13,7 @@ class GeocoderController extends Controller
|
|
|
13
13
|
/**
|
|
14
14
|
* Reverse geocodes the given coordinates and returns the results as JSON.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
16
|
+
* @param Request $request the HTTP request object
|
|
17
17
|
*
|
|
18
18
|
* @return \Illuminate\Http\Response the JSON response with the geocoded results
|
|
19
19
|
*/
|
|
@@ -57,7 +57,7 @@ class GeocoderController extends Controller
|
|
|
57
57
|
/**
|
|
58
58
|
* Geocodes the given query and returns the results as JSON.
|
|
59
59
|
*
|
|
60
|
-
* @param
|
|
60
|
+
* @param Request $request the HTTP request object
|
|
61
61
|
*
|
|
62
62
|
* @return \Illuminate\Http\Response the JSON response with the geocoded results
|
|
63
63
|
*/
|
|
@@ -94,7 +94,7 @@ class OrderController extends FleetOpsController
|
|
|
94
94
|
|
|
95
95
|
// If order creation includes files assosciate each to this order
|
|
96
96
|
if ($uploads) {
|
|
97
|
-
$ids
|
|
97
|
+
$ids = collect($uploads)->pluck('uuid');
|
|
98
98
|
$files = File::whereIn('uuid', $ids)->get();
|
|
99
99
|
|
|
100
100
|
foreach ($files as $file) {
|
|
@@ -339,7 +339,7 @@ class OrderController extends FleetOpsController
|
|
|
339
339
|
public function start(Request $request)
|
|
340
340
|
{
|
|
341
341
|
/**
|
|
342
|
-
* @var
|
|
342
|
+
* @var Order
|
|
343
343
|
*/
|
|
344
344
|
$order = Order::where('uuid', $request->input('order'))->withoutGlobalScopes()->first();
|
|
345
345
|
|
|
@@ -352,12 +352,12 @@ class OrderController extends FleetOpsController
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
/**
|
|
355
|
-
* @var
|
|
355
|
+
* @var Driver
|
|
356
356
|
*/
|
|
357
357
|
$driver = Driver::where('uuid', $order->driver_assigned_uuid)->withoutGlobalScopes()->first();
|
|
358
358
|
|
|
359
359
|
/**
|
|
360
|
-
* @var
|
|
360
|
+
* @var Payload
|
|
361
361
|
*/
|
|
362
362
|
$payload = Payload::where('uuid', $order->payload_uuid)->withoutGlobalScopes()->with(['waypoints', 'waypointMarkers', 'entities'])->first();
|
|
363
363
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
-
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
6
|
use Fleetbase\Http\Resources\Comment;
|
|
7
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
8
8
|
use Fleetbase\Support\Http;
|
|
9
9
|
use Fleetbase\Support\Resolve;
|
|
10
10
|
|
|
@@ -17,13 +17,13 @@ class ServiceQuoteItem extends FleetbaseResource
|
|
|
17
17
|
public function toArray($request)
|
|
18
18
|
{
|
|
19
19
|
return [
|
|
20
|
-
'id'
|
|
21
|
-
'uuid'
|
|
20
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
21
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
22
22
|
'service_quote_uuid' => $this->when(Http::isInternalRequest(), $this->service_quote_uuid),
|
|
23
|
-
'amount'
|
|
24
|
-
'currency'
|
|
25
|
-
'details'
|
|
26
|
-
'code'
|
|
23
|
+
'amount' => $this->amount,
|
|
24
|
+
'currency' => $this->currency,
|
|
25
|
+
'details' => $this->details,
|
|
26
|
+
'code' => $this->code,
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -76,7 +76,7 @@ class Lalamove
|
|
|
76
76
|
*/
|
|
77
77
|
private ?IntegratedVendor $integratedVendor = null;
|
|
78
78
|
|
|
79
|
-
public function __construct(string $apiKey = null, string $apiSecret = null, bool $sandbox = false, $market = null)
|
|
79
|
+
public function __construct(?string $apiKey = null, ?string $apiSecret = null, bool $sandbox = false, $market = null)
|
|
80
80
|
{
|
|
81
81
|
if ($apiKey === null) {
|
|
82
82
|
$apiKey = config('services.lalamove.key');
|
|
@@ -109,7 +109,7 @@ class Lalamove
|
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
public static function instance(string $apiKey = null, string $apiSecret = null, bool $sandbox = false, $market = null): Lalamove
|
|
112
|
+
public static function instance(?string $apiKey = null, ?string $apiSecret = null, bool $sandbox = false, $market = null): Lalamove
|
|
113
113
|
{
|
|
114
114
|
return new static($apiKey, $apiSecret, $market, $sandbox);
|
|
115
115
|
}
|
|
@@ -169,7 +169,7 @@ class Lalamove
|
|
|
169
169
|
return $this;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
public static function createServiceQuoteFromQuotation($quotation, $requestId = null, $integratedVendor = null, Payload $payload = null): ServiceQuote
|
|
172
|
+
public static function createServiceQuoteFromQuotation($quotation, $requestId = null, $integratedVendor = null, ?Payload $payload = null): ServiceQuote
|
|
173
173
|
{
|
|
174
174
|
$serviceQuote = static::serviceQuoteFromQuotation($quotation, $requestId, $integratedVendor, $payload);
|
|
175
175
|
$serviceQuote->save();
|
|
@@ -182,7 +182,7 @@ class Lalamove
|
|
|
182
182
|
return $serviceQuote->load(['items']);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
public static function serviceQuoteFromQuotation($quotation = null, $requestId = null, $integratedVendor = null, Payload $payload = null): ServiceQuote
|
|
185
|
+
public static function serviceQuoteFromQuotation($quotation = null, $requestId = null, $integratedVendor = null, ?Payload $payload = null): ServiceQuote
|
|
186
186
|
{
|
|
187
187
|
if (!$quotation) {
|
|
188
188
|
return null;
|
|
@@ -651,7 +651,7 @@ class Lalamove
|
|
|
651
651
|
return $this->createOrder($quotationId, $sender, $recipients, false, $isPODEnabled, $metadata);
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
-
public function setWebhook(string $webhookUrl = null)
|
|
654
|
+
public function setWebhook(?string $webhookUrl = null)
|
|
655
655
|
{
|
|
656
656
|
if (!is_string($webhookUrl)) {
|
|
657
657
|
return;
|
|
@@ -48,8 +48,8 @@ class SimulateDrivingRoute implements ShouldQueue
|
|
|
48
48
|
/**
|
|
49
49
|
* Create a new job instance.
|
|
50
50
|
*
|
|
51
|
-
* @param
|
|
52
|
-
* @param array
|
|
51
|
+
* @param Driver $driver the driver for whom the route is being simulated
|
|
52
|
+
* @param array $waypoints the waypoints that make up the route
|
|
53
53
|
*/
|
|
54
54
|
public function __construct(Driver $driver, array $waypoints = [])
|
|
55
55
|
{
|
|
@@ -23,12 +23,12 @@ class SimulateWaypointReached implements ShouldQueue
|
|
|
23
23
|
use SerializesModels;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @var
|
|
26
|
+
* @var Driver the driver for whom the waypoint is being simulated
|
|
27
27
|
*/
|
|
28
28
|
public Driver $driver;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* @var
|
|
31
|
+
* @var Point the waypoint that the driver is simulated to have reached
|
|
32
32
|
*/
|
|
33
33
|
public Point $waypoint;
|
|
34
34
|
|
|
@@ -24,7 +24,7 @@ class HandleOrderDispatchFailed implements ShouldQueue
|
|
|
24
24
|
/** @var \Fleetbase\FleetOps\Models\Order $order */
|
|
25
25
|
$order = $event->getModelRecord();
|
|
26
26
|
|
|
27
|
-
/** @var
|
|
27
|
+
/** @var User */
|
|
28
28
|
$createdBy = User::where('uuid', $order->created_by_uuid)->first();
|
|
29
29
|
|
|
30
30
|
// notify driver assigned order was canceled
|
|
@@ -22,7 +22,7 @@ class HandleOrderDriverAssigned implements ShouldQueue
|
|
|
22
22
|
*/
|
|
23
23
|
public function handle(OrderDriverAssigned $event)
|
|
24
24
|
{
|
|
25
|
-
/** @var
|
|
25
|
+
/** @var Order $order */
|
|
26
26
|
$order = $event->getModelRecord();
|
|
27
27
|
|
|
28
28
|
// halt if unable to resolve order record from event
|
|
@@ -30,7 +30,7 @@ class HandleOrderDriverAssigned implements ShouldQueue
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/** @var
|
|
33
|
+
/** @var Driver */
|
|
34
34
|
$driver = Driver::where('uuid', $order->driver_assigned_uuid)->withoutGlobalScopes()->first();
|
|
35
35
|
$order->setRelation('driverAssigned', $driver);
|
|
36
36
|
|
|
@@ -498,9 +498,9 @@ class Driver extends Model
|
|
|
498
498
|
*
|
|
499
499
|
* @param Order|null $order The order to consider when updating the position (default: null)
|
|
500
500
|
*
|
|
501
|
-
* @return
|
|
501
|
+
* @return Position|null The created Position object, or null if no new position was created
|
|
502
502
|
*/
|
|
503
|
-
public function updatePosition(Order $order = null): ?Position
|
|
503
|
+
public function updatePosition(?Order $order = null): ?Position
|
|
504
504
|
{
|
|
505
505
|
$position = null;
|
|
506
506
|
$lastPosition = $this->positions()->whereCompanyUuid(session('company'))->latest()->first();
|
|
@@ -273,7 +273,7 @@ class Entity extends Model
|
|
|
273
273
|
/**
|
|
274
274
|
* The length the entity belongs to.
|
|
275
275
|
*
|
|
276
|
-
* @var
|
|
276
|
+
* @var 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
|
|
286
|
+
* @var Length
|
|
287
287
|
*/
|
|
288
288
|
public function getWidthUnitAttribute()
|
|
289
289
|
{
|
|
@@ -416,7 +416,7 @@ class Entity extends Model
|
|
|
416
416
|
return $this;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
public static function insertGetUuid($values = [], Payload $payload = null)
|
|
419
|
+
public static function insertGetUuid($values = [], ?Payload $payload = null)
|
|
420
420
|
{
|
|
421
421
|
if (is_array($values) && isset($values['uuid'])) {
|
|
422
422
|
Entity::where('uuid', $values['uuid'])->update([
|
|
@@ -244,7 +244,7 @@ class Order extends Model
|
|
|
244
244
|
*/
|
|
245
245
|
public function transaction()
|
|
246
246
|
{
|
|
247
|
-
return $this->belongsTo(
|
|
247
|
+
return $this->belongsTo(Transaction::class);
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
/**
|
|
@@ -586,7 +586,7 @@ class Order extends Model
|
|
|
586
586
|
/**
|
|
587
587
|
* Set the order type attribute, which defaults to `default`.
|
|
588
588
|
*/
|
|
589
|
-
public function setTypeAttribute(string $type = null): void
|
|
589
|
+
public function setTypeAttribute(?string $type = null): void
|
|
590
590
|
{
|
|
591
591
|
$this->attributes['type'] = is_string($type) ? Str::slug($type) : 'default';
|
|
592
592
|
}
|
|
@@ -594,7 +594,7 @@ class Order extends Model
|
|
|
594
594
|
/**
|
|
595
595
|
* Set the order status attribute, which defaults to `created`.
|
|
596
596
|
*/
|
|
597
|
-
public function setStatusAttribute(string $status = null): void
|
|
597
|
+
public function setStatusAttribute(?string $status = null): void
|
|
598
598
|
{
|
|
599
599
|
$this->attributes['status'] = is_string($status) ? Str::snake($status) : 'created';
|
|
600
600
|
}
|
|
@@ -979,7 +979,7 @@ class Order extends Model
|
|
|
979
979
|
}
|
|
980
980
|
}
|
|
981
981
|
|
|
982
|
-
public function updateActivity(array $activity = null, $proof = null): Order
|
|
982
|
+
public function updateActivity(?array $activity = null, $proof = null): Order
|
|
983
983
|
{
|
|
984
984
|
$status = data_get($activity, 'status');
|
|
985
985
|
$details = data_get($activity, 'details', '');
|
|
@@ -562,7 +562,7 @@ class Payload extends Model
|
|
|
562
562
|
/**
|
|
563
563
|
* Get the pickup location for the payload.
|
|
564
564
|
*
|
|
565
|
-
* @return
|
|
565
|
+
* @return Point
|
|
566
566
|
*/
|
|
567
567
|
public function getPickupLocation()
|
|
568
568
|
{
|
|
@@ -653,8 +653,8 @@ class Payload extends Model
|
|
|
653
653
|
/**
|
|
654
654
|
* Set the first waypoint and update activity.
|
|
655
655
|
*
|
|
656
|
-
* @param array
|
|
657
|
-
* @param
|
|
656
|
+
* @param array $activity
|
|
657
|
+
* @param Point $location
|
|
658
658
|
*
|
|
659
659
|
* @return void
|
|
660
660
|
*/
|
|
@@ -682,9 +682,9 @@ class Payload extends Model
|
|
|
682
682
|
/**
|
|
683
683
|
* Update the current waypoint activity and it's entities.
|
|
684
684
|
*
|
|
685
|
-
* @param array
|
|
686
|
-
* @param
|
|
687
|
-
* @param \Fleetbase\Models\Proof|string|null
|
|
685
|
+
* @param array $activity
|
|
686
|
+
* @param Point $location
|
|
687
|
+
* @param \Fleetbase\Models\Proof|string|null $proof resolvable proof of delivery/activity
|
|
688
688
|
*
|
|
689
689
|
* @return $this
|
|
690
690
|
*/
|
|
@@ -743,14 +743,14 @@ class Payload extends Model
|
|
|
743
743
|
$order = $this->order;
|
|
744
744
|
|
|
745
745
|
// set google matrix based distance and time
|
|
746
|
-
if ($order instanceof
|
|
746
|
+
if ($order instanceof Order) {
|
|
747
747
|
return $order->setDistanceAndTime();
|
|
748
748
|
}
|
|
749
749
|
|
|
750
750
|
return null;
|
|
751
751
|
}
|
|
752
752
|
|
|
753
|
-
public function findDestinationFromKey(string $destinationKey = null): ?Place
|
|
753
|
+
public function findDestinationFromKey(?string $destinationKey = null): ?Place
|
|
754
754
|
{
|
|
755
755
|
if ($destinationKey === null) {
|
|
756
756
|
return null;
|
|
@@ -179,7 +179,7 @@ class Place extends Model
|
|
|
179
179
|
/**
|
|
180
180
|
* Fills empty address attributes with Google address attributes.
|
|
181
181
|
*
|
|
182
|
-
* @return
|
|
182
|
+
* @return Place $this
|
|
183
183
|
*/
|
|
184
184
|
public function fillWithGoogleAddress(\Geocoder\Provider\GoogleMaps\Model\GoogleAddress $address): Place
|
|
185
185
|
{
|
|
@@ -18,8 +18,8 @@ use Fleetbase\Traits\TracksApiCredential;
|
|
|
18
18
|
use Illuminate\Support\Arr;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* @var
|
|
22
|
-
* @var
|
|
21
|
+
* @var Point $location
|
|
22
|
+
* @var MultiPolygon $border
|
|
23
23
|
*/
|
|
24
24
|
class ServiceArea extends Model
|
|
25
25
|
{
|
|
@@ -130,10 +130,10 @@ class ServiceArea extends Model
|
|
|
130
130
|
/**
|
|
131
131
|
* Creates a polygon from a given point and radius.
|
|
132
132
|
*
|
|
133
|
-
* @param
|
|
134
|
-
* @param int
|
|
133
|
+
* @param Point $point the central point from which to create the polygon
|
|
134
|
+
* @param int $meters The radius in meters for the polygon. Default is 500 meters.
|
|
135
135
|
*
|
|
136
|
-
* @return
|
|
136
|
+
* @return Polygon returns a Polygon object
|
|
137
137
|
*/
|
|
138
138
|
public static function createPolygonFromPoint(Point $point, int $meters = 500): Polygon
|
|
139
139
|
{
|
|
@@ -150,10 +150,10 @@ class ServiceArea extends Model
|
|
|
150
150
|
/**
|
|
151
151
|
* Creates a multi-polygon from a given point and radius.
|
|
152
152
|
*
|
|
153
|
-
* @param
|
|
154
|
-
* @param int
|
|
153
|
+
* @param Point $point the central point from which to create the multi-polygon
|
|
154
|
+
* @param int $meters The radius in meters for the multi-polygon. Default is 500 meters.
|
|
155
155
|
*
|
|
156
|
-
* @return
|
|
156
|
+
* @return MultiPolygon returns a MultiPolygon object
|
|
157
157
|
*/
|
|
158
158
|
public static function createMultiPolygonFromPoint(Point $point, int $meters = 500): MultiPolygon
|
|
159
159
|
{
|
|
@@ -180,7 +180,7 @@ class ServiceArea extends Model
|
|
|
180
180
|
/**
|
|
181
181
|
* Retrieves the location attribute as a point.
|
|
182
182
|
*
|
|
183
|
-
* @return
|
|
183
|
+
* @return Point returns the centroid of the border as a Point object
|
|
184
184
|
*/
|
|
185
185
|
public function getLocationAttribute(): Point
|
|
186
186
|
{
|
|
@@ -378,7 +378,7 @@ class ServiceRate extends Model
|
|
|
378
378
|
*
|
|
379
379
|
* @return array an array of applicable service rates
|
|
380
380
|
*/
|
|
381
|
-
public static function getServicableForWaypoints($waypoints = [],
|
|
381
|
+
public static function getServicableForWaypoints($waypoints = [], ?\Closure $queryCallback = null): array
|
|
382
382
|
{
|
|
383
383
|
$reader = new GeoJSONReader();
|
|
384
384
|
$applicableServiceRates = [];
|
|
@@ -440,7 +440,7 @@ class ServiceRate extends Model
|
|
|
440
440
|
*
|
|
441
441
|
* @return array an array of applicable service rates
|
|
442
442
|
*/
|
|
443
|
-
public static function getServicableForPlaces($places = [], $service = null, $currency = null,
|
|
443
|
+
public static function getServicableForPlaces($places = [], $service = null, $currency = null, ?\Closure $queryCallback = null): array
|
|
444
444
|
{
|
|
445
445
|
$reader = new GeoJSONReader();
|
|
446
446
|
$applicableServiceRates = [];
|
|
@@ -223,7 +223,7 @@ class TrackingNumber extends Model
|
|
|
223
223
|
throw (new \Illuminate\Database\Eloquent\ModelNotFoundException())->setModel(static::class, $id);
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
public function updateOwnerStatus(TrackingStatus $trackingStatus = null)
|
|
226
|
+
public function updateOwnerStatus(?TrackingStatus $trackingStatus = null)
|
|
227
227
|
{
|
|
228
228
|
$trackingStatus = $trackingStatus ?? $this->load(['status'])->getRelationValue('status');
|
|
229
229
|
// update status on owner
|
|
@@ -239,7 +239,7 @@ class TrackingNumber extends Model
|
|
|
239
239
|
return $this;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
public static function insertGetUuid($values = [], Model $owner = null)
|
|
242
|
+
public static function insertGetUuid($values = [], ?Model $owner = null)
|
|
243
243
|
{
|
|
244
244
|
$instance = new static();
|
|
245
245
|
$fillable = $instance->getFillable();
|
|
@@ -144,7 +144,7 @@ class TrackingStatus extends Model
|
|
|
144
144
|
return $string;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
public static function insertGetUuid($values = [], TrackingNumber $trackingNumber = null)
|
|
147
|
+
public static function insertGetUuid($values = [], ?TrackingNumber $trackingNumber = null)
|
|
148
148
|
{
|
|
149
149
|
$instance = new static();
|
|
150
150
|
$fillable = $instance->getFillable();
|
|
@@ -392,11 +392,11 @@ class Vehicle extends Model
|
|
|
392
392
|
* Updates the position of the vehicle, creating a new Position record if
|
|
393
393
|
* the driver has moved more than 100 meters or if it's their first recorded position.
|
|
394
394
|
*
|
|
395
|
-
* @param
|
|
395
|
+
* @param Order|null $order The order to consider when updating the position (default: null)
|
|
396
396
|
*
|
|
397
|
-
* @return
|
|
397
|
+
* @return Position|null The created Position object, or null if no new position was created
|
|
398
398
|
*/
|
|
399
|
-
public function updatePositionWithOrderContext(Order $order = null): ?Position
|
|
399
|
+
public function updatePositionWithOrderContext(?Order $order = null): ?Position
|
|
400
400
|
{
|
|
401
401
|
$position = null;
|
|
402
402
|
$lastPosition = $this->positions()->whereCompanyUuid(session('company'))->latest()->first();
|
|
@@ -182,7 +182,7 @@ class Waypoint extends Model
|
|
|
182
182
|
return data_get($this, 'trackingNumber.last_status_code');
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
public static function insertGetUuid($values = [], Payload $payload = null)
|
|
185
|
+
public static function insertGetUuid($values = [], ?Payload $payload = null)
|
|
186
186
|
{
|
|
187
187
|
$instance = new static();
|
|
188
188
|
$fillable = $instance->getFillable();
|
|
@@ -104,7 +104,7 @@ class Zone extends Model
|
|
|
104
104
|
/**
|
|
105
105
|
* Retrieves the location attribute as a point.
|
|
106
106
|
*
|
|
107
|
-
* @return
|
|
107
|
+
* @return Point returns the centroid of the border as a Point object
|
|
108
108
|
*/
|
|
109
109
|
public function getLocationAttribute(): Point
|
|
110
110
|
{
|
|
@@ -195,10 +195,10 @@ class Zone extends Model
|
|
|
195
195
|
/**
|
|
196
196
|
* Creates a polygon from a given point and radius.
|
|
197
197
|
*
|
|
198
|
-
* @param
|
|
199
|
-
* @param int
|
|
198
|
+
* @param Point $point the central point from which to create the polygon
|
|
199
|
+
* @param int $meters The radius in meters for the polygon. Default is 500 meters.
|
|
200
200
|
*
|
|
201
|
-
* @return
|
|
201
|
+
* @return Polygon returns a Polygon object
|
|
202
202
|
*/
|
|
203
203
|
public static function createPolygonFromPoint(Point $point, int $meters = 500): Polygon
|
|
204
204
|
{
|
|
@@ -84,7 +84,7 @@ class OrderAssigned extends Notification implements ShouldQueue
|
|
|
84
84
|
/**
|
|
85
85
|
* Get the mail representation of the notification.
|
|
86
86
|
*
|
|
87
|
-
* @return
|
|
87
|
+
* @return MailMessage
|
|
88
88
|
*/
|
|
89
89
|
public function toMail($notifiable)
|
|
90
90
|
{
|
|
@@ -84,7 +84,7 @@ class OrderCanceled extends Notification implements ShouldQueue
|
|
|
84
84
|
/**
|
|
85
85
|
* Get the mail representation of the notification.
|
|
86
86
|
*
|
|
87
|
-
* @return
|
|
87
|
+
* @return MailMessage
|
|
88
88
|
*/
|
|
89
89
|
public function toMail($notifiable)
|
|
90
90
|
{
|
|
@@ -84,7 +84,7 @@ class OrderDispatchFailed extends Notification implements ShouldQueue
|
|
|
84
84
|
/**
|
|
85
85
|
* Get the mail representation of the notification.
|
|
86
86
|
*
|
|
87
|
-
* @return
|
|
87
|
+
* @return MailMessage
|
|
88
88
|
*/
|
|
89
89
|
public function toMail($notifiable)
|
|
90
90
|
{
|
|
@@ -129,7 +129,7 @@ class OrderDispatched extends Notification implements ShouldQueue
|
|
|
129
129
|
/**
|
|
130
130
|
* Get the mail representation of the notification.
|
|
131
131
|
*
|
|
132
|
-
* @return
|
|
132
|
+
* @return MailMessage
|
|
133
133
|
*/
|
|
134
134
|
public function toMail($notifiable)
|
|
135
135
|
{
|
|
@@ -47,7 +47,7 @@ class Flow
|
|
|
47
47
|
$authored = $authoredQuery->get();
|
|
48
48
|
|
|
49
49
|
// create array of configs
|
|
50
|
-
/** @var
|
|
50
|
+
/** @var Collection $configs */
|
|
51
51
|
$configs = collect([...$installedExtensions, ...$authored]);
|
|
52
52
|
|
|
53
53
|
// if no installed configs always place default config
|
|
@@ -79,7 +79,7 @@ class Flow
|
|
|
79
79
|
$authored = Extension::where(['author_uuid' => session('company'), 'meta_type' => 'order_config', 'status' => 'private'])->get();
|
|
80
80
|
|
|
81
81
|
// create array of configs
|
|
82
|
-
/** @var
|
|
82
|
+
/** @var Collection $configs */
|
|
83
83
|
$configs = collect([...$installedExtensions, ...$authored]);
|
|
84
84
|
|
|
85
85
|
// if no installed configs always place default config
|
|
@@ -111,7 +111,7 @@ class Flow
|
|
|
111
111
|
$authored = Extension::where(['author_uuid' => $order->company_uuid, 'meta_type' => 'order_config', 'status' => 'private'])->get();
|
|
112
112
|
|
|
113
113
|
// create array of configs
|
|
114
|
-
/** @var
|
|
114
|
+
/** @var Collection $configs */
|
|
115
115
|
$configs = collect([...$installedExtensions, ...$authored]);
|
|
116
116
|
|
|
117
117
|
// if no installed configs always place default config
|
|
@@ -259,7 +259,7 @@ class Flow
|
|
|
259
259
|
/**
|
|
260
260
|
* Returns a order flow status for the waypoint only.
|
|
261
261
|
*/
|
|
262
|
-
public static function getOrderWaypointFlow(Order $order, Waypoint $waypoint = null): ?array
|
|
262
|
+
public static function getOrderWaypointFlow(Order $order, ?Waypoint $waypoint = null): ?array
|
|
263
263
|
{
|
|
264
264
|
if ($waypoint === null) {
|
|
265
265
|
/** @var \Fleetbase\Models\Waypoint $waypoint */
|
|
@@ -293,7 +293,7 @@ class Flow
|
|
|
293
293
|
/**
|
|
294
294
|
* Returns a order flow status for the waypoint only.
|
|
295
295
|
*/
|
|
296
|
-
public static function getOrderFlowVars(Order $order, Waypoint $currentWaypoint = null): ?array
|
|
296
|
+
public static function getOrderFlowVars(Order $order, ?Waypoint $currentWaypoint = null): ?array
|
|
297
297
|
{
|
|
298
298
|
$vars = [];
|
|
299
299
|
$allWaypoints = data_get($order, 'payload.waypoints', collect());
|
|
@@ -603,7 +603,7 @@ class Flow
|
|
|
603
603
|
|
|
604
604
|
public static function getAllDefaultOrderConfigs(): Collection
|
|
605
605
|
{
|
|
606
|
-
/** @var
|
|
606
|
+
/** @var Collection $extensions */
|
|
607
607
|
$extensions = collect();
|
|
608
608
|
$company = static::getCompanySession();
|
|
609
609
|
$orderConfigs = config('api.types.order', []);
|
|
@@ -125,7 +125,7 @@ class Geocoding
|
|
|
125
125
|
*
|
|
126
126
|
* @throws \Exception
|
|
127
127
|
*/
|
|
128
|
-
public static function reverseFromCoordinates($latitude, $longitude, string $searchQuery = null): Collection
|
|
128
|
+
public static function reverseFromCoordinates($latitude, $longitude, ?string $searchQuery = null): Collection
|
|
129
129
|
{
|
|
130
130
|
$httpClient = new Client();
|
|
131
131
|
$provider = new GoogleMaps($httpClient, null, config('services.google_maps.api_key', env('GOOGLE_MAPS_API_KEY')));
|
|
@@ -169,7 +169,7 @@ class ResolvedIntegratedVendor
|
|
|
169
169
|
return json_encode($this->toArray());
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
public function callback(string $callback = null, ...$callbackParams)
|
|
172
|
+
public function callback(?string $callback = null, ...$callbackParams)
|
|
173
173
|
{
|
|
174
174
|
if (!is_string($callback)) {
|
|
175
175
|
return;
|
|
@@ -25,7 +25,7 @@ class Metrics
|
|
|
25
25
|
protected Company $company;
|
|
26
26
|
protected array $metrics = [];
|
|
27
27
|
|
|
28
|
-
public static function new(Company $company,
|
|
28
|
+
public static function new(Company $company, ?\DateTime $start = null, ?\DateTime $end = null): Metrics
|
|
29
29
|
{
|
|
30
30
|
$start = $start === null ? Carbon::create(1900)->toDateTime() : $start;
|
|
31
31
|
$end = $end === null ? Carbon::tomorrow()->toDateTime() : $end;
|
|
@@ -33,7 +33,7 @@ class Metrics
|
|
|
33
33
|
return (new static())->setCompany($company)->between($start, $end);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
public static function forCompany(Company $company,
|
|
36
|
+
public static function forCompany(Company $company, ?\DateTime $start = null, ?\DateTime $end = null): Metrics
|
|
37
37
|
{
|
|
38
38
|
return static::new($company, $start, $end);
|
|
39
39
|
}
|
|
@@ -106,7 +106,7 @@ class Metrics
|
|
|
106
106
|
return $this;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
public function earnings(callable $callback = null): Metrics
|
|
109
|
+
public function earnings(?callable $callback = null): Metrics
|
|
110
110
|
{
|
|
111
111
|
$query = Transaction::where('company_uuid', $this->company->uuid)->whereBetween('created_at', [$this->start, $this->end]);
|
|
112
112
|
|
|
@@ -119,7 +119,7 @@ class Metrics
|
|
|
119
119
|
return $this->set('earnings', (int) $data);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
public function fuelCosts(callable $callback = null): Metrics
|
|
122
|
+
public function fuelCosts(?callable $callback = null): Metrics
|
|
123
123
|
{
|
|
124
124
|
$query = FuelReport::where('company_uuid', $this->company->uuid)->whereBetween('created_at', [$this->start, $this->end]);
|
|
125
125
|
|
|
@@ -132,7 +132,7 @@ class Metrics
|
|
|
132
132
|
return $this->set('fuel_costs', (int) $data);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
public function totalDistanceTraveled(callable $callback = null): Metrics
|
|
135
|
+
public function totalDistanceTraveled(?callable $callback = null): Metrics
|
|
136
136
|
{
|
|
137
137
|
$query = Order::where(
|
|
138
138
|
[
|
|
@@ -151,7 +151,7 @@ class Metrics
|
|
|
151
151
|
return $this->set('total_distance_traveled', (int) $data);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
public function totalTimeTraveled(callable $callback = null): Metrics
|
|
154
|
+
public function totalTimeTraveled(?callable $callback = null): Metrics
|
|
155
155
|
{
|
|
156
156
|
$query = Order::where(
|
|
157
157
|
[
|
|
@@ -170,7 +170,7 @@ class Metrics
|
|
|
170
170
|
return $this->set('total_distance_traveled', (int) $data);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
public function ordersCanceled(callable $callback = null): Metrics
|
|
173
|
+
public function ordersCanceled(?callable $callback = null): Metrics
|
|
174
174
|
{
|
|
175
175
|
$query = Order::where('company_uuid', $this->company->uuid)
|
|
176
176
|
->whereBetween('created_at', [$this->start, $this->end])
|
|
@@ -185,7 +185,7 @@ class Metrics
|
|
|
185
185
|
return $this->set('orders_canceled', $data);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
public function ordersCompleted(callable $callback = null): Metrics
|
|
188
|
+
public function ordersCompleted(?callable $callback = null): Metrics
|
|
189
189
|
{
|
|
190
190
|
$query = Order::where('company_uuid', $this->company->uuid)
|
|
191
191
|
->whereBetween('created_at', [$this->start, $this->end])
|
|
@@ -200,7 +200,7 @@ class Metrics
|
|
|
200
200
|
return $this->set('orders_completed', $data);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
public function ordersInProgress(callable $callback = null): Metrics
|
|
203
|
+
public function ordersInProgress(?callable $callback = null): Metrics
|
|
204
204
|
{
|
|
205
205
|
$query = Order::where('company_uuid', $this->company->uuid)
|
|
206
206
|
->whereBetween('created_at', [$this->start, $this->end])
|
|
@@ -215,7 +215,7 @@ class Metrics
|
|
|
215
215
|
return $this->set('orders_in_progress', $data);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
public function ordersScheduled(callable $callback = null): Metrics
|
|
218
|
+
public function ordersScheduled(?callable $callback = null): Metrics
|
|
219
219
|
{
|
|
220
220
|
$query = Order::where('company_uuid', $this->company->uuid)
|
|
221
221
|
->whereBetween('created_at', [$this->start, $this->end])
|
|
@@ -231,7 +231,7 @@ class Metrics
|
|
|
231
231
|
return $this->set('orders_scheduled', $data);
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
public function driversOnline(callable $callback = null): Metrics
|
|
234
|
+
public function driversOnline(?callable $callback = null): Metrics
|
|
235
235
|
{
|
|
236
236
|
$query = Driver::where('company_uuid', $this->company->uuid)
|
|
237
237
|
->where('online', true)
|
|
@@ -246,7 +246,7 @@ class Metrics
|
|
|
246
246
|
return $this->set('drivers_online', $data);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
public function totalDrivers(callable $callback = null): Metrics
|
|
249
|
+
public function totalDrivers(?callable $callback = null): Metrics
|
|
250
250
|
{
|
|
251
251
|
$query = Driver::where('company_uuid', $this->company->uuid);
|
|
252
252
|
|
|
@@ -259,7 +259,7 @@ class Metrics
|
|
|
259
259
|
return $this->set('total_drivers', $data);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
public function totalCustomers(callable $callback = null): Metrics
|
|
262
|
+
public function totalCustomers(?callable $callback = null): Metrics
|
|
263
263
|
{
|
|
264
264
|
$query = Contact::where('company_uuid', $this->company->uuid)
|
|
265
265
|
->where('type', 'customer');
|
|
@@ -273,7 +273,7 @@ class Metrics
|
|
|
273
273
|
return $this->set('total_customers', $data);
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
public function openIssues(callable $callback = null): Metrics
|
|
276
|
+
public function openIssues(?callable $callback = null): Metrics
|
|
277
277
|
{
|
|
278
278
|
$query = Issue::where('company_uuid', session('company'))
|
|
279
279
|
->whereBetween('created_at', [$this->start, $this->end])
|
|
@@ -288,7 +288,7 @@ class Metrics
|
|
|
288
288
|
return $this->set('open_issues', $data);
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
public function resolvedIssues(callable $callback = null): Metrics
|
|
291
|
+
public function resolvedIssues(?callable $callback = null): Metrics
|
|
292
292
|
{
|
|
293
293
|
$query = Issue::where('company_uuid', session('company'))
|
|
294
294
|
->whereBetween('created_at', [$this->start, $this->end])
|
package/server/src/routes.php
CHANGED
|
@@ -23,7 +23,7 @@ Route::prefix(config('fleetops.api.routing.prefix', null))->namespace('Fleetbase
|
|
|
23
23
|
| End-user API routes, these are routes that the SDK and applications will interface with, and require API credentials.
|
|
24
24
|
*/
|
|
25
25
|
Route::prefix('v1')
|
|
26
|
-
->middleware(['fleetbase.api',
|
|
26
|
+
->middleware(['fleetbase.api', Fleetbase\FleetOps\Http\Middleware\TransformLocationMiddleware::class])
|
|
27
27
|
->namespace('Api\v1')
|
|
28
28
|
->group(function ($router) {
|
|
29
29
|
// drivers routes
|
|
@@ -194,7 +194,7 @@ Route::prefix(config('fleetops.api.routing.prefix', null))->namespace('Fleetbase
|
|
|
194
194
|
});
|
|
195
195
|
|
|
196
196
|
// auth:sanctum
|
|
197
|
-
$router->group(['middleware' => ['fleetbase.protected',
|
|
197
|
+
$router->group(['middleware' => ['fleetbase.protected', Fleetbase\FleetOps\Http\Middleware\TransformLocationMiddleware::class]], function () use ($router) {
|
|
198
198
|
$router->group(['prefix' => 'orders'], function () use ($router) {
|
|
199
199
|
$router->post('/', 'Api\v1\OrderController@create');
|
|
200
200
|
$router->get('/', 'Api\v1\OrderController@query');
|
|
@@ -249,7 +249,7 @@ Route::prefix(config('fleetops.api.routing.prefix', null))->namespace('Fleetbase
|
|
|
249
249
|
);
|
|
250
250
|
|
|
251
251
|
$router->group(
|
|
252
|
-
['prefix' => 'v1', 'namespace' => 'v1', 'middleware' => ['fleetbase.protected',
|
|
252
|
+
['prefix' => 'v1', 'namespace' => 'v1', 'middleware' => ['fleetbase.protected', Fleetbase\FleetOps\Http\Middleware\TransformLocationMiddleware::class]],
|
|
253
253
|
function ($router) {
|
|
254
254
|
$router->fleetbaseRoutes(
|
|
255
255
|
'contacts',
|