@fleetbase/fleetops-engine 0.4.9 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbase/fleetops-api",
3
- "version": "0.4.9",
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.3",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "Fleet-Ops",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "Fleet & Transport Management Extension for Fleetbase",
5
5
  "repository": "https://github.com/fleetbase/fleetops",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetbase/fleetops-engine",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "Fleet & Transport Management Extension for Fleetbase",
5
5
  "fleetbase": {
6
6
  "route": "fleet-ops"
@@ -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
- $userDetails['company_uuid'] = session('company');
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'] = session('company');
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\AndroidConfig;
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
- $notification = \NotificationChannels\Fcm\Resources\Notification::create()
112
- ->setTitle('New order ' . $this->order->public_id . ' assigned!')
113
- ->setBody('You have a new order assigned, tap for details.');
114
-
115
- if ($this->order->isScheduled) {
116
- $notification->setBody('You have a new order scheduled for ' . $this->order->scheduled_at);
117
- }
118
-
119
- $message = FcmMessage::create()
120
- ->setData(['id' => $this->order->public_id, 'type' => 'order_assigned'])
121
- ->setNotification($notification)
122
- ->setAndroid(
123
- AndroidConfig::create()
124
- ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
125
- ->setNotification(AndroidNotification::create()->setColor('#4391EA'))
126
- )->setApns(
127
- ApnsConfig::create()
128
- ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios'))
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\AndroidConfig;
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
- $notification = \NotificationChannels\Fcm\Resources\Notification::create()
109
- ->setTitle('Order ' . $this->order->public_id . ' was canceled')
110
- ->setBody('No further action is necessary.');
111
-
112
- $message = FcmMessage::create()
113
- ->setData(['id' => $this->order->public_id, 'type' => 'order_canceled'])
114
- ->setNotification($notification)
115
- ->setAndroid(
116
- AndroidConfig::create()
117
- ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
118
- ->setNotification(AndroidNotification::create()->setColor('#4391EA'))
119
- )->setApns(
120
- ApnsConfig::create()
121
- ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios'))
122
- );
123
-
124
- return $message;
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\AndroidConfig;
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
- $notification = \NotificationChannels\Fcm\Resources\Notification::create()
153
- ->setTitle('Order ' . $this->order->public_id . ' has been dispatched!')
154
- ->setBody('An order has just been dispatched to you and is ready to be started.');
155
-
156
- $message = FcmMessage::create()
157
- ->setData(['id' => $this->order->public_id, 'type' => 'order_dispatched'])
158
- ->setNotification($notification)
159
- ->setAndroid(
160
- AndroidConfig::create()
161
- ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
162
- ->setNotification(AndroidNotification::create()->setColor('#4391EA'))
163
- )->setApns(
164
- ApnsConfig::create()
165
- ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios'))
166
- );
167
-
168
- return $message;
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\AndroidConfig;
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
- $notification = \NotificationChannels\Fcm\Resources\Notification::create()
142
- ->setTitle('New incoming order!')
143
- ->setBody($this->distance ? 'New order available for pickup about ' . Utils::formatMeters($this->distance, false) . ' away' : 'New order is available for pickup.');
144
-
145
- $message = FcmMessage::create()
146
- ->setData(['id' => $this->order->public_id, 'type' => 'order_ping'])
147
- ->setNotification($notification)
148
- ->setAndroid(
149
- AndroidConfig::create()
150
- ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics'))
151
- ->setNotification(AndroidNotification::create()->setColor('#4391EA'))
152
- )->setApns(
153
- ApnsConfig::create()
154
- ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios'))
155
- );
156
-
157
- return $message;
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
  /**