@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
|
@@ -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
|
{
|
|
@@ -13,11 +13,7 @@ use NotificationChannels\Apn\ApnChannel;
|
|
|
13
13
|
use NotificationChannels\Apn\ApnMessage;
|
|
14
14
|
use NotificationChannels\Fcm\FcmChannel;
|
|
15
15
|
use NotificationChannels\Fcm\FcmMessage;
|
|
16
|
-
use NotificationChannels\Fcm\Resources\
|
|
17
|
-
use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
|
|
18
|
-
use NotificationChannels\Fcm\Resources\AndroidNotification;
|
|
19
|
-
use NotificationChannels\Fcm\Resources\ApnsConfig;
|
|
20
|
-
use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
|
|
16
|
+
use NotificationChannels\Fcm\Resources\Notification as FcmNotification;
|
|
21
17
|
|
|
22
18
|
class OrderAssigned extends Notification implements ShouldQueue
|
|
23
19
|
{
|
|
@@ -84,7 +80,7 @@ class OrderAssigned extends Notification implements ShouldQueue
|
|
|
84
80
|
/**
|
|
85
81
|
* Get the mail representation of the notification.
|
|
86
82
|
*
|
|
87
|
-
* @return
|
|
83
|
+
* @return MailMessage
|
|
88
84
|
*/
|
|
89
85
|
public function toMail($notifiable)
|
|
90
86
|
{
|
|
@@ -108,27 +104,26 @@ class OrderAssigned extends Notification implements ShouldQueue
|
|
|
108
104
|
*/
|
|
109
105
|
public function toFcm($notifiable)
|
|
110
106
|
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
->
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return $message;
|
|
107
|
+
return (new FcmMessage(notification: new FcmNotification(
|
|
108
|
+
title: 'New order ' . $this->order->public_id . ' assigned!',
|
|
109
|
+
body: $this->order->isScheduled ? 'You have a new order scheduled for ' . $this->order->scheduled_at : 'You have a new order assigned, tap for details.',
|
|
110
|
+
)))
|
|
111
|
+
->data(['id' => $this->order->public_id, 'type' => 'order_assigned'])
|
|
112
|
+
->custom([
|
|
113
|
+
'android' => [
|
|
114
|
+
'notification' => [
|
|
115
|
+
'color' => '#4391EA',
|
|
116
|
+
],
|
|
117
|
+
'fcm_options' => [
|
|
118
|
+
'analytics_label' => 'analytics',
|
|
119
|
+
],
|
|
120
|
+
],
|
|
121
|
+
'apns' => [
|
|
122
|
+
'fcm_options' => [
|
|
123
|
+
'analytics_label' => 'analytics',
|
|
124
|
+
],
|
|
125
|
+
],
|
|
126
|
+
]);
|
|
132
127
|
}
|
|
133
128
|
|
|
134
129
|
/**
|
|
@@ -13,11 +13,7 @@ use NotificationChannels\Apn\ApnChannel;
|
|
|
13
13
|
use NotificationChannels\Apn\ApnMessage;
|
|
14
14
|
use NotificationChannels\Fcm\FcmChannel;
|
|
15
15
|
use NotificationChannels\Fcm\FcmMessage;
|
|
16
|
-
use NotificationChannels\Fcm\Resources\
|
|
17
|
-
use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
|
|
18
|
-
use NotificationChannels\Fcm\Resources\AndroidNotification;
|
|
19
|
-
use NotificationChannels\Fcm\Resources\ApnsConfig;
|
|
20
|
-
use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
|
|
16
|
+
use NotificationChannels\Fcm\Resources\Notification as FcmNotification;
|
|
21
17
|
|
|
22
18
|
class OrderCanceled extends Notification implements ShouldQueue
|
|
23
19
|
{
|
|
@@ -84,7 +80,7 @@ class OrderCanceled extends Notification implements ShouldQueue
|
|
|
84
80
|
/**
|
|
85
81
|
* Get the mail representation of the notification.
|
|
86
82
|
*
|
|
87
|
-
* @return
|
|
83
|
+
* @return MailMessage
|
|
88
84
|
*/
|
|
89
85
|
public function toMail($notifiable)
|
|
90
86
|
{
|
|
@@ -105,23 +101,26 @@ class OrderCanceled extends Notification implements ShouldQueue
|
|
|
105
101
|
*/
|
|
106
102
|
public function toFcm($notifiable)
|
|
107
103
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
$
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
104
|
+
return (new FcmMessage(notification: new FcmNotification(
|
|
105
|
+
title: 'Order ' . $this->order->public_id . ' was canceled',
|
|
106
|
+
body: 'No further action is necessary.',
|
|
107
|
+
)))
|
|
108
|
+
->data(['id' => $this->order->public_id, 'type' => 'order_canceled'])
|
|
109
|
+
->custom([
|
|
110
|
+
'android' => [
|
|
111
|
+
'notification' => [
|
|
112
|
+
'color' => '#4391EA',
|
|
113
|
+
],
|
|
114
|
+
'fcm_options' => [
|
|
115
|
+
'analytics_label' => 'analytics',
|
|
116
|
+
],
|
|
117
|
+
],
|
|
118
|
+
'apns' => [
|
|
119
|
+
'fcm_options' => [
|
|
120
|
+
'analytics_label' => 'analytics',
|
|
121
|
+
],
|
|
122
|
+
],
|
|
123
|
+
]);
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
/**
|
|
@@ -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
|
{
|
|
@@ -16,11 +16,7 @@ use NotificationChannels\Apn\ApnChannel;
|
|
|
16
16
|
use NotificationChannels\Apn\ApnMessage;
|
|
17
17
|
use NotificationChannels\Fcm\FcmChannel;
|
|
18
18
|
use NotificationChannels\Fcm\FcmMessage;
|
|
19
|
-
use NotificationChannels\Fcm\Resources\
|
|
20
|
-
use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
|
|
21
|
-
use NotificationChannels\Fcm\Resources\AndroidNotification;
|
|
22
|
-
use NotificationChannels\Fcm\Resources\ApnsConfig;
|
|
23
|
-
use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
|
|
19
|
+
use NotificationChannels\Fcm\Resources\Notification as FcmNotification;
|
|
24
20
|
|
|
25
21
|
class OrderDispatched extends Notification implements ShouldQueue
|
|
26
22
|
{
|
|
@@ -129,7 +125,7 @@ class OrderDispatched extends Notification implements ShouldQueue
|
|
|
129
125
|
/**
|
|
130
126
|
* Get the mail representation of the notification.
|
|
131
127
|
*
|
|
132
|
-
* @return
|
|
128
|
+
* @return MailMessage
|
|
133
129
|
*/
|
|
134
130
|
public function toMail($notifiable)
|
|
135
131
|
{
|
|
@@ -149,23 +145,26 @@ class OrderDispatched extends Notification implements ShouldQueue
|
|
|
149
145
|
*/
|
|
150
146
|
public function toFcm($notifiable)
|
|
151
147
|
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
$
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
148
|
+
return (new FcmMessage(notification: new FcmNotification(
|
|
149
|
+
title: 'Order ' . $this->order->public_id . ' has been dispatched!',
|
|
150
|
+
body: 'An order has just been dispatched to you and is ready to be started.',
|
|
151
|
+
)))
|
|
152
|
+
->data(['id' => $this->order->public_id, 'type' => 'order_dispatched'])
|
|
153
|
+
->custom([
|
|
154
|
+
'android' => [
|
|
155
|
+
'notification' => [
|
|
156
|
+
'color' => '#4391EA',
|
|
157
|
+
],
|
|
158
|
+
'fcm_options' => [
|
|
159
|
+
'analytics_label' => 'analytics',
|
|
160
|
+
],
|
|
161
|
+
],
|
|
162
|
+
'apns' => [
|
|
163
|
+
'fcm_options' => [
|
|
164
|
+
'analytics_label' => 'analytics',
|
|
165
|
+
],
|
|
166
|
+
],
|
|
167
|
+
]);
|
|
169
168
|
}
|
|
170
169
|
|
|
171
170
|
/**
|
|
@@ -15,11 +15,7 @@ use NotificationChannels\Apn\ApnChannel;
|
|
|
15
15
|
use NotificationChannels\Apn\ApnMessage;
|
|
16
16
|
use NotificationChannels\Fcm\FcmChannel;
|
|
17
17
|
use NotificationChannels\Fcm\FcmMessage;
|
|
18
|
-
use NotificationChannels\Fcm\Resources\
|
|
19
|
-
use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
|
|
20
|
-
use NotificationChannels\Fcm\Resources\AndroidNotification;
|
|
21
|
-
use NotificationChannels\Fcm\Resources\ApnsConfig;
|
|
22
|
-
use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
|
|
18
|
+
use NotificationChannels\Fcm\Resources\Notification as FcmNotification;
|
|
23
19
|
|
|
24
20
|
class OrderPing extends Notification implements ShouldQueue
|
|
25
21
|
{
|
|
@@ -138,23 +134,26 @@ class OrderPing extends Notification implements ShouldQueue
|
|
|
138
134
|
*/
|
|
139
135
|
public function toFcm($notifiable)
|
|
140
136
|
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
$
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
137
|
+
return (new FcmMessage(notification: new FcmNotification(
|
|
138
|
+
title: 'New incoming order!',
|
|
139
|
+
body: $this->distance ? 'New order available for pickup about ' . Utils::formatMeters($this->distance, false) . ' away' : 'New order is available for pickup.',
|
|
140
|
+
)))
|
|
141
|
+
->data(['id' => $this->order->public_id, 'type' => 'order_ping'])
|
|
142
|
+
->custom([
|
|
143
|
+
'android' => [
|
|
144
|
+
'notification' => [
|
|
145
|
+
'color' => '#4391EA',
|
|
146
|
+
],
|
|
147
|
+
'fcm_options' => [
|
|
148
|
+
'analytics_label' => 'analytics',
|
|
149
|
+
],
|
|
150
|
+
],
|
|
151
|
+
'apns' => [
|
|
152
|
+
'fcm_options' => [
|
|
153
|
+
'analytics_label' => 'analytics',
|
|
154
|
+
],
|
|
155
|
+
],
|
|
156
|
+
]);
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
/**
|
|
@@ -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;
|