@fleetbase/fleetops-engine 0.4.8 → 0.4.10
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/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 +28 -20
- 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 +9 -11
- 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 +22 -27
- package/server/src/Notifications/OrderCanceled.php +22 -23
- package/server/src/Notifications/OrderDispatchFailed.php +1 -1
- package/server/src/Notifications/OrderDispatched.php +22 -23
- package/server/src/Notifications/OrderPing.php +21 -22
- 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
package/composer.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetbase/fleetops-api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
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.4",
|
|
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
|
+
}
|
|
@@ -46,15 +46,26 @@ class DriverController extends Controller
|
|
|
46
46
|
$input = $request->except(['name', 'password', 'email', 'phone', 'location', 'altitude', 'heading', 'speed', 'meta']);
|
|
47
47
|
|
|
48
48
|
// get user details for driver
|
|
49
|
-
$userDetails = $request->only(['name', 'password', 'email', 'phone']);
|
|
50
|
-
|
|
49
|
+
$userDetails = $request->only(['name', 'password', 'email', 'phone', 'timezone']);
|
|
50
|
+
|
|
51
|
+
// Get current company session
|
|
52
|
+
$company = Auth::getCompany();
|
|
53
|
+
|
|
54
|
+
// Apply user infos
|
|
55
|
+
$userDetails = User::applyUserInfoFromRequest($request, $userDetails);
|
|
51
56
|
|
|
52
57
|
// create user account for driver
|
|
53
58
|
$user = User::create($userDetails);
|
|
54
59
|
|
|
60
|
+
// Assign company
|
|
61
|
+
$user->assignCompany($company);
|
|
62
|
+
|
|
63
|
+
// Set user type
|
|
64
|
+
$user->setUserType('driver');
|
|
65
|
+
|
|
55
66
|
// set user id
|
|
56
67
|
$input['user_uuid'] = $user->uuid;
|
|
57
|
-
$input['company_uuid'] =
|
|
68
|
+
$input['company_uuid'] = $company->uuid;
|
|
58
69
|
|
|
59
70
|
// vehicle assignment public_id -> uuid
|
|
60
71
|
if ($request->has('vehicle')) {
|
|
@@ -354,7 +365,7 @@ class DriverController extends Controller
|
|
|
354
365
|
/**
|
|
355
366
|
* Authenticates customer using login credentials and returns with auth token.
|
|
356
367
|
*
|
|
357
|
-
* @return
|
|
368
|
+
* @return DriverResource
|
|
358
369
|
*/
|
|
359
370
|
public function login(Request $request)
|
|
360
371
|
{
|
|
@@ -418,9 +429,11 @@ class DriverController extends Controller
|
|
|
418
429
|
|
|
419
430
|
// generate verification token
|
|
420
431
|
try {
|
|
421
|
-
VerificationCode::generateSmsVerificationFor($user, 'driver_login',
|
|
422
|
-
|
|
423
|
-
|
|
432
|
+
VerificationCode::generateSmsVerificationFor($user, 'driver_login', [
|
|
433
|
+
'messageCallback' => function ($verification) use ($company) {
|
|
434
|
+
return 'Your ' . data_get($company, 'name', config('app.name')) . ' verification code is ' . $verification->code;
|
|
435
|
+
},
|
|
436
|
+
]);
|
|
424
437
|
} catch (\Throwable $e) {
|
|
425
438
|
if (app()->bound('sentry')) {
|
|
426
439
|
app('sentry')->captureException($e);
|
|
@@ -435,7 +448,7 @@ class DriverController extends Controller
|
|
|
435
448
|
/**
|
|
436
449
|
* Verifys SMS code and sends auth token with customer resource.
|
|
437
450
|
*
|
|
438
|
-
* @return
|
|
451
|
+
* @return DriverResource
|
|
439
452
|
*/
|
|
440
453
|
public function verifyCode(Request $request)
|
|
441
454
|
{
|
|
@@ -489,11 +502,9 @@ class DriverController extends Controller
|
|
|
489
502
|
}
|
|
490
503
|
|
|
491
504
|
/**
|
|
492
|
-
* Gets the current organization/company for the driver
|
|
505
|
+
* Gets the current organization/company for the driver.
|
|
493
506
|
*
|
|
494
|
-
* @
|
|
495
|
-
* @param \Illuminate\Http\Request $request
|
|
496
|
-
* @return \Fleetbase\Http\Resources\Organization
|
|
507
|
+
* @return Organization
|
|
497
508
|
*/
|
|
498
509
|
public function currentOrganization(string $id, Request $request)
|
|
499
510
|
{
|
|
@@ -521,7 +532,7 @@ class DriverController extends Controller
|
|
|
521
532
|
/**
|
|
522
533
|
* List organizations that driver is apart of.
|
|
523
534
|
*
|
|
524
|
-
* @return
|
|
535
|
+
* @return Organization
|
|
525
536
|
*/
|
|
526
537
|
public function listOrganizations(string $id, Request $request)
|
|
527
538
|
{
|
|
@@ -546,7 +557,7 @@ class DriverController extends Controller
|
|
|
546
557
|
/**
|
|
547
558
|
* Allow driver to switch organization.
|
|
548
559
|
*
|
|
549
|
-
* @return
|
|
560
|
+
* @return Organization
|
|
550
561
|
*/
|
|
551
562
|
public function switchOrganization(string $id, SwitchOrganizationRequest $request)
|
|
552
563
|
{
|
|
@@ -604,7 +615,7 @@ class DriverController extends Controller
|
|
|
604
615
|
$order = $request->input('order');
|
|
605
616
|
|
|
606
617
|
try {
|
|
607
|
-
/** @var
|
|
618
|
+
/** @var Driver $driver */
|
|
608
619
|
$driver = Driver::findRecordOrFail($id, ['user']);
|
|
609
620
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) {
|
|
610
621
|
return response()->json(
|
|
@@ -617,7 +628,7 @@ class DriverController extends Controller
|
|
|
617
628
|
|
|
618
629
|
if ($order) {
|
|
619
630
|
try {
|
|
620
|
-
/** @var
|
|
631
|
+
/** @var Order $order */
|
|
621
632
|
$order = Order::findRecordOrFail($order, ['payload']);
|
|
622
633
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) {
|
|
623
634
|
return response()->json(
|
|
@@ -720,9 +731,6 @@ class DriverController extends Controller
|
|
|
720
731
|
|
|
721
732
|
/**
|
|
722
733
|
* Get the drivers current company using their user account.
|
|
723
|
-
*
|
|
724
|
-
* @param \Fleetbase\Models\User $user
|
|
725
|
-
* @return \Fleetbase\Models\Company|null
|
|
726
734
|
*/
|
|
727
735
|
private static function getDriverCompanyFromUser(User $user): ?Company
|
|
728
736
|
{
|
|
@@ -747,7 +755,7 @@ class DriverController extends Controller
|
|
|
747
755
|
/**
|
|
748
756
|
* Patches phone number with international code.
|
|
749
757
|
*/
|
|
750
|
-
private static function phone(string $phone = null): string
|
|
758
|
+
private static function phone(?string $phone = null): string
|
|
751
759
|
{
|
|
752
760
|
if ($phone === null) {
|
|
753
761
|
$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
|
*/
|
|
@@ -111,13 +111,6 @@ class DriverController extends FleetOpsController
|
|
|
111
111
|
// Assign user to company
|
|
112
112
|
if ($company) {
|
|
113
113
|
$existingUser->assignCompany($company);
|
|
114
|
-
|
|
115
|
-
// create company user
|
|
116
|
-
CompanyUser::create([
|
|
117
|
-
'user_uuid' => $existingUser->uuid,
|
|
118
|
-
'company_uuid' => $company->uuid,
|
|
119
|
-
'status' => $isOrganizationMember ? 'active' : 'pending'
|
|
120
|
-
]);
|
|
121
114
|
}
|
|
122
115
|
|
|
123
116
|
if (!$isOrganizationMember) {
|
|
@@ -174,6 +167,9 @@ class DriverController extends FleetOpsController
|
|
|
174
167
|
$company = Auth::getCompany();
|
|
175
168
|
$userInput['company_uuid'] = session('company', $company->uuid);
|
|
176
169
|
|
|
170
|
+
// Apply user infos
|
|
171
|
+
$userInput = User::applyUserInfoFromRequest($request, $userInput);
|
|
172
|
+
|
|
177
173
|
// Create user account
|
|
178
174
|
$user = User::create($userInput);
|
|
179
175
|
|
|
@@ -397,9 +393,11 @@ class DriverController extends FleetOpsController
|
|
|
397
393
|
}
|
|
398
394
|
|
|
399
395
|
// Generate verification token
|
|
400
|
-
VerificationCode::generateSmsVerificationFor($user, 'driver_login',
|
|
401
|
-
|
|
402
|
-
|
|
396
|
+
VerificationCode::generateSmsVerificationFor($user, 'driver_login', [
|
|
397
|
+
'messageCallback' => function ($verification) {
|
|
398
|
+
return 'Your ' . config('app.name') . ' verification code is ' . $verification->code;
|
|
399
|
+
},
|
|
400
|
+
]);
|
|
403
401
|
|
|
404
402
|
return response()->json(['status' => 'OK']);
|
|
405
403
|
}
|
|
@@ -453,7 +451,7 @@ class DriverController extends FleetOpsController
|
|
|
453
451
|
/**
|
|
454
452
|
* Patches phone number with international code.
|
|
455
453
|
*/
|
|
456
|
-
public static function phone(string $phone = null): string
|
|
454
|
+
public static function phone(?string $phone = null): string
|
|
457
455
|
{
|
|
458
456
|
if ($phone === null) {
|
|
459
457
|
$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', '');
|