@fleetbase/fleetops-engine 0.4.9 → 0.4.11
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/Http/Controllers/Api/v1/DriverController.php +14 -3
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +3 -7
- package/server/src/Notifications/OrderAssigned.php +21 -26
- package/server/src/Notifications/OrderCanceled.php +21 -22
- package/server/src/Notifications/OrderDispatched.php +21 -22
- package/server/src/Notifications/OrderPing.php +21 -22
- package/server/src/Support/DistanceMatrix.php +2 -2
- package/server/src/Support/Utils.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.11",
|
|
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
|
@@ -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')) {
|
|
@@ -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
|
|
|
@@ -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
|
{
|
|
@@ -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
|
{
|
|
@@ -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
|
/**
|
|
@@ -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
|
{
|
|
@@ -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
|
/**
|
|
@@ -17,9 +17,9 @@ namespace Fleetbase\FleetOps\Support;
|
|
|
17
17
|
class DistanceMatrix
|
|
18
18
|
{
|
|
19
19
|
public ?float $distance;
|
|
20
|
-
public ?
|
|
20
|
+
public ?float $time;
|
|
21
21
|
|
|
22
|
-
public function __construct(?float $distance, ?
|
|
22
|
+
public function __construct(?float $distance, ?float $time)
|
|
23
23
|
{
|
|
24
24
|
$this->distance = $distance;
|
|
25
25
|
$this->time = $time;
|
|
@@ -783,8 +783,8 @@ class Utils extends FleetbaseUtils
|
|
|
783
783
|
]
|
|
784
784
|
)->json();
|
|
785
785
|
|
|
786
|
-
$distance = data_get($response, 'rows.0.elements.0.distance.value');
|
|
787
|
-
$time = data_get($response, 'rows.0.elements.0.duration.value');
|
|
786
|
+
$distance = (float) data_get($response, 'rows.0.elements.0.distance.value', 0);
|
|
787
|
+
$time = (float) data_get($response, 'rows.0.elements.0.duration.value', 0);
|
|
788
788
|
|
|
789
789
|
$result = static::createObject(
|
|
790
790
|
[
|
|
@@ -812,7 +812,7 @@ class Utils extends FleetbaseUtils
|
|
|
812
812
|
$destination = static::getPointFromMixed($destination);
|
|
813
813
|
|
|
814
814
|
$distance = Utils::vincentyGreatCircleDistance($origin, $destination);
|
|
815
|
-
$time = round($distance / 100) * self::DRIVING_TIME_MULTIPLIER;
|
|
815
|
+
$time = (float) round($distance / 100) * self::DRIVING_TIME_MULTIPLIER;
|
|
816
816
|
|
|
817
817
|
return new DistanceMatrix($distance, $time);
|
|
818
818
|
}
|