@fleetbase/storefront-engine 0.2.4 → 0.2.6

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.
Files changed (140) hide show
  1. package/README.md +4 -4
  2. package/addon/components/modals/import-products.hbs +1 -1
  3. package/addon/components/schedule-manager.hbs +2 -2
  4. package/addon/components/widget/customers.hbs +1 -1
  5. package/addon/components/widget/customers.js +7 -4
  6. package/addon/components/widget/orders.js +4 -0
  7. package/addon/controllers/base-controller.js +31 -0
  8. package/addon/controllers/networks/index/network.js +2 -2
  9. package/addon/controllers/networks/index.js +3 -2
  10. package/addon/controllers/products/index/category/new.js +14 -11
  11. package/addon/controllers/products/index/category.js +2 -2
  12. package/addon/controllers/products/index/index.js +2 -2
  13. package/addon/controllers/products/index.js +2 -3
  14. package/addon/models/network.js +0 -1
  15. package/addon/models/product-addon-category.js +10 -1
  16. package/addon/models/product-variant.js +0 -2
  17. package/addon/models/product.js +35 -2
  18. package/addon/routes/customers/index.js +11 -1
  19. package/addon/routes/networks/index.js +9 -0
  20. package/addon/routes/orders/index.js +11 -1
  21. package/addon/routes/products/index.js +8 -2
  22. package/addon/serializers/product.js +16 -0
  23. package/addon/services/storefront.js +81 -0
  24. package/addon/templates/networks/index/network/stores.hbs +2 -2
  25. package/addon/templates/networks/index/network.hbs +1 -1
  26. package/addon/templates/products/index/category/new.hbs +3 -3
  27. package/addon/templates/products/index/category.hbs +20 -3
  28. package/app/controllers/base-controller.js +1 -0
  29. package/assets/sounds/storefront_order_alert.mp3 +0 -0
  30. package/composer.json +3 -3
  31. package/config/environment.js +11 -1
  32. package/extension.json +1 -1
  33. package/index.js +15 -0
  34. package/package.json +132 -125
  35. package/server/src/Auth/Schemas/Storefront.php +31 -39
  36. package/server/src/Console/Commands/NotifyStorefrontOrderNearby.php +9 -11
  37. package/server/src/Expansions/ContactFilterExpansion.php +36 -0
  38. package/server/src/Expansions/EntityExpansion.php +12 -12
  39. package/server/src/Expansions/OrderFilterExpansion.php +31 -0
  40. package/server/src/Expansions/VendorFilterExpansion.php +36 -0
  41. package/server/src/Http/Controllers/ActionController.php +9 -11
  42. package/server/src/Http/Controllers/AddonCategoryController.php +1 -1
  43. package/server/src/Http/Controllers/CustomerController.php +1 -1
  44. package/server/src/Http/Controllers/GatewayController.php +1 -1
  45. package/server/src/Http/Controllers/MetricsController.php +17 -17
  46. package/server/src/Http/Controllers/NetworkController.php +16 -26
  47. package/server/src/Http/Controllers/NotificationChannelController.php +1 -1
  48. package/server/src/Http/Controllers/OrderController.php +18 -22
  49. package/server/src/Http/Controllers/ProductAddonCategoryController.php +1 -2
  50. package/server/src/Http/Controllers/ProductAddonController.php +1 -2
  51. package/server/src/Http/Controllers/ProductController.php +89 -44
  52. package/server/src/Http/Controllers/ProductHourController.php +1 -1
  53. package/server/src/Http/Controllers/ProductVariantController.php +1 -1
  54. package/server/src/Http/Controllers/ProductVariantOptionController.php +1 -1
  55. package/server/src/Http/Controllers/ReviewController.php +1 -1
  56. package/server/src/Http/Controllers/StoreController.php +1 -2
  57. package/server/src/Http/Controllers/StoreHourController.php +1 -1
  58. package/server/src/Http/Controllers/StoreLocationController.php +1 -1
  59. package/server/src/Http/Controllers/StorefrontController.php +0 -2
  60. package/server/src/Http/Controllers/VoteController.php +1 -1
  61. package/server/src/Http/Controllers/v1/CartController.php +16 -26
  62. package/server/src/Http/Controllers/v1/CategoryController.php +3 -4
  63. package/server/src/Http/Controllers/v1/CheckoutController.php +283 -286
  64. package/server/src/Http/Controllers/v1/CustomerController.php +54 -67
  65. package/server/src/Http/Controllers/v1/GatewayControllerController.php +0 -2
  66. package/server/src/Http/Controllers/v1/NetworkController.php +26 -23
  67. package/server/src/Http/Controllers/v1/PaymentMethodController.php +0 -2
  68. package/server/src/Http/Controllers/v1/ProductController.php +1 -4
  69. package/server/src/Http/Controllers/v1/ReviewController.php +31 -35
  70. package/server/src/Http/Controllers/v1/ServiceQuoteController.php +57 -53
  71. package/server/src/Http/Controllers/v1/StoreController.php +8 -16
  72. package/server/src/Http/Filter/AddonCategoryFilter.php +1 -1
  73. package/server/src/Http/Filter/OrderFilter.php +2 -2
  74. package/server/src/Http/Middleware/SetStorefrontSession.php +9 -20
  75. package/server/src/Http/Requests/AddStoreToNetworkCategory.php +3 -3
  76. package/server/src/Http/Requests/CreateCustomerRequest.php +5 -7
  77. package/server/src/Http/Requests/CreateReviewRequest.php +4 -5
  78. package/server/src/Http/Requests/GetServiceQuoteFromCart.php +2 -2
  79. package/server/src/Http/Requests/InitializeCheckoutRequest.php +5 -5
  80. package/server/src/Http/Requests/NetworkActionRequest.php +2 -2
  81. package/server/src/Http/Requests/VerifyCreateCustomerRequest.php +2 -2
  82. package/server/src/Http/Resources/Cart.php +20 -11
  83. package/server/src/Http/Resources/Category.php +12 -11
  84. package/server/src/Http/Resources/Customer.php +15 -14
  85. package/server/src/Http/Resources/Gateway.php +12 -11
  86. package/server/src/Http/Resources/Media.php +9 -8
  87. package/server/src/Http/Resources/Network.php +33 -28
  88. package/server/src/Http/Resources/Product.php +89 -81
  89. package/server/src/Http/Resources/Review.php +14 -13
  90. package/server/src/Http/Resources/ReviewCustomer.php +12 -11
  91. package/server/src/Http/Resources/Store.php +39 -33
  92. package/server/src/Http/Resources/StoreHour.php +9 -8
  93. package/server/src/Http/Resources/StoreLocation.php +9 -9
  94. package/server/src/Imports/ProductsImport.php +0 -2
  95. package/server/src/Jobs/DownloadProductImageUrl.php +7 -4
  96. package/server/src/Listeners/HandleOrderCompleted.php +2 -1
  97. package/server/src/Listeners/HandleOrderDispatched.php +2 -1
  98. package/server/src/Listeners/HandleOrderDriverAssigned.php +2 -1
  99. package/server/src/Listeners/HandleOrderStarted.php +4 -3
  100. package/server/src/Mail/StorefrontNetworkInvite.php +7 -6
  101. package/server/src/Models/AddonCategory.php +2 -4
  102. package/server/src/Models/Cart.php +117 -124
  103. package/server/src/Models/Checkout.php +14 -12
  104. package/server/src/Models/Customer.php +9 -9
  105. package/server/src/Models/Gateway.php +22 -22
  106. package/server/src/Models/Network.php +41 -52
  107. package/server/src/Models/NetworkStore.php +6 -5
  108. package/server/src/Models/NotificationChannel.php +11 -9
  109. package/server/src/Models/PaymentMethod.php +9 -7
  110. package/server/src/Models/Product.php +152 -30
  111. package/server/src/Models/ProductAddon.php +14 -11
  112. package/server/src/Models/ProductAddonCategory.php +9 -8
  113. package/server/src/Models/ProductHour.php +6 -5
  114. package/server/src/Models/ProductStoreLocation.php +7 -5
  115. package/server/src/Models/ProductVariant.php +15 -11
  116. package/server/src/Models/ProductVariantOption.php +12 -9
  117. package/server/src/Models/Review.php +9 -7
  118. package/server/src/Models/Store.php +68 -84
  119. package/server/src/Models/StoreHour.php +6 -5
  120. package/server/src/Models/StoreLocation.php +12 -8
  121. package/server/src/Models/StorefrontModel.php +1 -1
  122. package/server/src/Models/Vote.php +8 -6
  123. package/server/src/Notifications/StorefrontOrderCanceled.php +15 -19
  124. package/server/src/Notifications/StorefrontOrderCompleted.php +15 -19
  125. package/server/src/Notifications/StorefrontOrderCreated.php +31 -36
  126. package/server/src/Notifications/StorefrontOrderDriverAssigned.php +15 -20
  127. package/server/src/Notifications/StorefrontOrderEnroute.php +14 -19
  128. package/server/src/Notifications/StorefrontOrderNearby.php +16 -21
  129. package/server/src/Notifications/StorefrontOrderPreparing.php +15 -18
  130. package/server/src/Notifications/StorefrontOrderReadyForPickup.php +15 -18
  131. package/server/src/Observers/NetworkObserver.php +2 -3
  132. package/server/src/Observers/ProductObserver.php +17 -33
  133. package/server/src/Providers/EventServiceProvider.php +15 -4
  134. package/server/src/Providers/StorefrontServiceProvider.php +8 -10
  135. package/server/src/Support/Metrics.php +12 -12
  136. package/server/src/Support/OrderConfig.php +3 -2
  137. package/server/src/Support/QPay.php +22 -20
  138. package/server/src/Support/Storefront.php +18 -17
  139. package/server/src/routes.php +1 -1
  140. package/tsconfig.declarations.json +10 -0
@@ -2,26 +2,25 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Notifications;
4
4
 
5
- use Exception;
6
5
  use Fleetbase\FleetOps\Models\Order;
6
+ use Fleetbase\FleetOps\Support\Utils;
7
7
  use Fleetbase\Storefront\Models\NotificationChannel;
8
8
  use Fleetbase\Storefront\Support\Storefront;
9
- use Fleetbase\FleetOps\Support\Utils;
10
9
  use Illuminate\Bus\Queueable;
11
10
  // use Illuminate\Contracts\Queue\ShouldQueue;
12
11
  use Illuminate\Notifications\Messages\MailMessage;
13
12
  use Illuminate\Notifications\Notification;
14
- use NotificationChannels\Fcm\FcmChannel;
15
- use NotificationChannels\Fcm\FcmMessage;
16
13
  use NotificationChannels\Apn\ApnChannel;
17
14
  use NotificationChannels\Apn\ApnMessage;
15
+ use NotificationChannels\Fcm\FcmChannel;
16
+ use NotificationChannels\Fcm\FcmMessage;
18
17
  use NotificationChannels\Fcm\Resources\AndroidConfig;
19
18
  use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
20
19
  use NotificationChannels\Fcm\Resources\AndroidNotification;
21
20
  use NotificationChannels\Fcm\Resources\ApnsConfig;
22
21
  use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
23
- use Pushok\Client as PushOkClient;
24
22
  use Pushok\AuthProvider\Token as PuskOkToken;
23
+ use Pushok\Client as PushOkClient;
25
24
 
26
25
  class StorefrontOrderCompleted extends Notification
27
26
  {
@@ -37,14 +36,13 @@ class StorefrontOrderCompleted extends Notification
37
36
  */
38
37
  public function __construct(Order $order)
39
38
  {
40
- $this->order = $order->setRelations([]);
39
+ $this->order = $order->setRelations([]);
41
40
  $this->storefront = Storefront::findAbout($this->order->getMeta('storefront_id'));
42
41
  }
43
42
 
44
43
  /**
45
44
  * Get the notification's delivery channels.
46
45
  *
47
- * @param mixed $notifiable
48
46
  * @return array
49
47
  */
50
48
  public function via($notifiable)
@@ -72,12 +70,11 @@ class StorefrontOrderCompleted extends Notification
72
70
  /**
73
71
  * Get the mail representation of the notification.
74
72
  *
75
- * @param mixed $notifiable
76
73
  * @return \Illuminate\Notifications\Messages\MailMessage
77
74
  */
78
75
  public function toMail($notifiable)
79
76
  {
80
- $message = (new MailMessage)
77
+ $message = (new MailMessage())
81
78
  ->subject('Your order has been delivered')
82
79
  ->line('Your order has been delivered, enjoy!');
83
80
 
@@ -89,7 +86,6 @@ class StorefrontOrderCompleted extends Notification
89
86
  /**
90
87
  * Get the firebase cloud message representation of the notification.
91
88
  *
92
- * @param mixed $notifiable
93
89
  * @return array
94
90
  */
95
91
  public function toFcm($notifiable)
@@ -116,7 +112,6 @@ class StorefrontOrderCompleted extends Notification
116
112
  /**
117
113
  * Get the apns message representation of the notification.
118
114
  *
119
- * @param mixed $notifiable
120
115
  * @return array
121
116
  */
122
117
  public function toApn($notifiable)
@@ -126,13 +121,13 @@ class StorefrontOrderCompleted extends Notification
126
121
  if ($this->order->hasMeta('storefront_notification_channel')) {
127
122
  $notificationChannel = NotificationChannel::where([
128
123
  'owner_uuid' => $about->uuid,
129
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
130
- 'scheme' => 'apn'
124
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
125
+ 'scheme' => 'apn',
131
126
  ])->first();
132
127
  } else {
133
128
  $notificationChannel = NotificationChannel::where([
134
129
  'owner_uuid' => $about->uuid,
135
- 'scheme' => 'apn'
130
+ 'scheme' => 'apn',
136
131
  ])->first();
137
132
  }
138
133
 
@@ -140,8 +135,9 @@ class StorefrontOrderCompleted extends Notification
140
135
 
141
136
  try {
142
137
  $channelClient = new PushOkClient(PuskOkToken::create($config));
143
- } catch (Exception $e) {
138
+ } catch (\Exception $e) {
144
139
  app('sentry')->captureException($e);
140
+
145
141
  return;
146
142
  }
147
143
 
@@ -164,13 +160,13 @@ class StorefrontOrderCompleted extends Notification
164
160
  if ($this->order->hasMeta('storefront_notification_channel')) {
165
161
  $notificationChannel = NotificationChannel::where([
166
162
  'owner_uuid' => $about->uuid,
167
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
168
- 'scheme' => 'fcm'
163
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
164
+ 'scheme' => 'fcm',
169
165
  ])->first();
170
166
  } else {
171
167
  $notificationChannel = NotificationChannel::where([
172
168
  'owner_uuid' => $about->uuid,
173
- 'scheme' => 'fcm'
169
+ 'scheme' => 'fcm',
174
170
  ])->first();
175
171
  }
176
172
 
@@ -185,7 +181,7 @@ class StorefrontOrderCompleted extends Notification
185
181
 
186
182
  public function configureFcm($notificationChannel)
187
183
  {
188
- $config = (array) $notificationChannel->config;
184
+ $config = (array) $notificationChannel->config;
189
185
  $fcmConfig = config('firebase.projects.app');
190
186
 
191
187
  // set credentials
@@ -2,15 +2,15 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Notifications;
4
4
 
5
- use Illuminate\Bus\Queueable;
5
+ use Fleetbase\FleetOps\Models\Order;
6
6
  // use Illuminate\Contracts\Queue\ShouldQueue;
7
+ use Fleetbase\FleetOps\Support\Utils;
8
+ use Fleetbase\Storefront\Support\Storefront;
9
+ use Illuminate\Bus\Queueable;
7
10
  use Illuminate\Notifications\Messages\MailMessage;
8
11
  use Illuminate\Notifications\Notification;
9
12
  use NotificationChannels\Twilio\TwilioChannel;
10
13
  use NotificationChannels\Twilio\TwilioSmsMessage;
11
- use Fleetbase\FleetOps\Models\Order;
12
- use Fleetbase\Storefront\Support\Storefront;
13
- use Fleetbase\FleetOps\Support\Utils;
14
14
 
15
15
  class StorefrontOrderCreated extends Notification
16
16
  {
@@ -27,14 +27,13 @@ class StorefrontOrderCreated extends Notification
27
27
  {
28
28
  $storefrontId = $order->getMeta('storefront_id');
29
29
 
30
- $this->order = $order;
30
+ $this->order = $order;
31
31
  $this->storefront = Storefront::findAbout($storefrontId);
32
32
  }
33
33
 
34
34
  /**
35
35
  * Get the notification's delivery channels.
36
36
  *
37
- * @param mixed $notifiable
38
37
  * @return array
39
38
  */
40
39
  public function via($notifiable)
@@ -45,27 +44,26 @@ class StorefrontOrderCreated extends Notification
45
44
  /**
46
45
  * Get the twilio sms representation of the notification.
47
46
  *
48
- * @param mixed $notifiable
49
47
  * @return \NotificationChannels\Twilio\TwilioSmsMessage;
50
48
  */
51
49
  public function toTwilio($notifiable)
52
50
  {
53
- $storeName = $this->storefront->name;
54
- $isPickup = $this->order->getMeta('is_pickup');
51
+ $storeName = $this->storefront->name;
52
+ $isPickup = $this->order->getMeta('is_pickup');
55
53
  $isDelivery = !$isPickup;
56
- $method = $isPickup ? 'pickup' : 'delivery';
57
- $items = $this->order->payload->entities->map(function ($entity) {
54
+ $method = $isPickup ? 'pickup' : 'delivery';
55
+ $items = $this->order->payload->entities->map(function ($entity) {
58
56
  return $entity->name;
59
57
  })->join(',');
60
- $customerName = $this->order->customer->name;
61
- $customerPhone = $this->order->customer->phone;
58
+ $customerName = $this->order->customer->name;
59
+ $customerPhone = $this->order->customer->phone;
62
60
  $deliveryAddress = $this->order->payload->dropoff->address;
63
- $subtotal = $this->order->getMeta('subtotal');
64
- $deliveryFee = $this->order->getMeta('delivery_fee');
65
- $tip = $this->order->getMeta('tip');
66
- $deliveryTip = $this->order->getMeta('delivery_tip');
67
- $total = $this->order->getMeta('total');
68
- $currency = $this->order->getMeta('currency');
61
+ $subtotal = $this->order->getMeta('subtotal');
62
+ $deliveryFee = $this->order->getMeta('delivery_fee');
63
+ $tip = $this->order->getMeta('tip');
64
+ $deliveryTip = $this->order->getMeta('delivery_tip');
65
+ $total = $this->order->getMeta('total');
66
+ $currency = $this->order->getMeta('currency');
69
67
 
70
68
  $content = '🚨 ' . $storeName . ' has received new order!' . "\n\n" .
71
69
  'A new ' . $method . ' order was just created!' . "\n\n" .
@@ -94,29 +92,28 @@ class StorefrontOrderCreated extends Notification
94
92
  /**
95
93
  * Get the mail representation of the notification.
96
94
  *
97
- * @param mixed $notifiable
98
95
  * @return \Illuminate\Notifications\Messages\MailMessage
99
96
  */
100
97
  public function toMail($notifiable)
101
98
  {
102
- $storeName = $this->storefront->name;
103
- $isPickup = $this->order->getMeta('is_pickup');
99
+ $storeName = $this->storefront->name;
100
+ $isPickup = $this->order->getMeta('is_pickup');
104
101
  $isDelivery = !$isPickup;
105
- $method = $isPickup ? 'pickup' : 'delivery';
106
- $items = $this->order->payload->entities->map(function ($entity) {
102
+ $method = $isPickup ? 'pickup' : 'delivery';
103
+ $items = $this->order->payload->entities->map(function ($entity) {
107
104
  return $entity->name;
108
105
  })->join(',');
109
- $customerName = $this->order->customer->name;
110
- $customerPhone = $this->order->customer->phone;
106
+ $customerName = $this->order->customer->name;
107
+ $customerPhone = $this->order->customer->phone;
111
108
  $deliveryAddress = $this->order->payload->dropoff->address;
112
- $subtotal = $this->order->getMeta('subtotal');
113
- $deliveryFee = $this->order->getMeta('delivery_fee');
114
- $tip = $this->order->getMeta('tip');
115
- $deliveryTip = $this->order->getMeta('delivery_tip');
116
- $total = $this->order->getMeta('total');
117
- $currency = $this->order->getMeta('currency');
118
-
119
- $message = (new MailMessage)
109
+ $subtotal = $this->order->getMeta('subtotal');
110
+ $deliveryFee = $this->order->getMeta('delivery_fee');
111
+ $tip = $this->order->getMeta('tip');
112
+ $deliveryTip = $this->order->getMeta('delivery_tip');
113
+ $total = $this->order->getMeta('total');
114
+ $currency = $this->order->getMeta('currency');
115
+
116
+ $message = (new MailMessage())
120
117
  ->subject('🚨 ' . $storeName . ' has received new order!')
121
118
  ->greeting('Hello!')
122
119
  ->line('A new ' . $method . ' order was just created!')
@@ -145,13 +142,11 @@ class StorefrontOrderCreated extends Notification
145
142
  /**
146
143
  * Get the array representation of the notification.
147
144
  *
148
- * @param mixed $notifiable
149
145
  * @return array
150
146
  */
151
147
  public function toArray($notifiable)
152
148
  {
153
149
  return [
154
- //
155
150
  ];
156
151
  }
157
152
  }
@@ -2,27 +2,26 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Notifications;
4
4
 
5
- use Exception;
6
5
  use Fleetbase\FleetOps\Models\Order;
6
+ use Fleetbase\FleetOps\Support\Utils;
7
7
  use Fleetbase\Storefront\Models\NotificationChannel;
8
8
  use Fleetbase\Storefront\Support\Storefront;
9
- use Fleetbase\FleetOps\Support\Utils;
10
9
  // use Fleetbase\FleetOps\Support\Utils;
11
10
  use Illuminate\Bus\Queueable;
12
11
  // use Illuminate\Contracts\Queue\ShouldQueue;
13
12
  use Illuminate\Notifications\Messages\MailMessage;
14
13
  use Illuminate\Notifications\Notification;
15
- use NotificationChannels\Fcm\FcmChannel;
16
- use NotificationChannels\Fcm\FcmMessage;
17
14
  use NotificationChannels\Apn\ApnChannel;
18
15
  use NotificationChannels\Apn\ApnMessage;
16
+ use NotificationChannels\Fcm\FcmChannel;
17
+ use NotificationChannels\Fcm\FcmMessage;
19
18
  use NotificationChannels\Fcm\Resources\AndroidConfig;
20
19
  use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
21
20
  use NotificationChannels\Fcm\Resources\AndroidNotification;
22
21
  use NotificationChannels\Fcm\Resources\ApnsConfig;
23
22
  use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
24
- use Pushok\Client as PushOkClient;
25
23
  use Pushok\AuthProvider\Token as PuskOkToken;
24
+ use Pushok\Client as PushOkClient;
26
25
 
27
26
  class StorefrontOrderDriverAssigned extends Notification
28
27
  {
@@ -35,15 +34,14 @@ class StorefrontOrderDriverAssigned extends Notification
35
34
  */
36
35
  public function __construct(Order $order)
37
36
  {
38
- $this->order = $order->setRelations([]);
39
- $this->driver = $order->driverAssigned;
37
+ $this->order = $order->setRelations([]);
38
+ $this->driver = $order->driverAssigned;
40
39
  $this->storefront = Storefront::findAbout($this->order->getMeta('storefront_id'));
41
40
  }
42
41
 
43
42
  /**
44
43
  * Get the notification's delivery channels.
45
44
  *
46
- * @param mixed $notifiable
47
45
  * @return array
48
46
  */
49
47
  public function via($notifiable)
@@ -71,12 +69,11 @@ class StorefrontOrderDriverAssigned extends Notification
71
69
  /**
72
70
  * Get the mail representation of the notification.
73
71
  *
74
- * @param mixed $notifiable
75
72
  * @return \Illuminate\Notifications\Messages\MailMessage
76
73
  */
77
74
  public function toMail($notifiable)
78
75
  {
79
- $message = (new MailMessage)
76
+ $message = (new MailMessage())
80
77
  ->subject('Your order from ' . $this->storefront->name . ' is being prepared')
81
78
  ->line('Your order is getting started.');
82
79
 
@@ -88,7 +85,6 @@ class StorefrontOrderDriverAssigned extends Notification
88
85
  /**
89
86
  * Get the firebase cloud message representation of the notification.
90
87
  *
91
- * @param mixed $notifiable
92
88
  * @return array
93
89
  */
94
90
  public function toFcm($notifiable)
@@ -119,13 +115,13 @@ class StorefrontOrderDriverAssigned extends Notification
119
115
  if ($this->order->hasMeta('storefront_notification_channel')) {
120
116
  $notificationChannel = NotificationChannel::where([
121
117
  'owner_uuid' => $about->uuid,
122
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
123
- 'scheme' => 'fcm'
118
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
119
+ 'scheme' => 'fcm',
124
120
  ])->first();
125
121
  } else {
126
122
  $notificationChannel = NotificationChannel::where([
127
123
  'owner_uuid' => $about->uuid,
128
- 'scheme' => 'fcm'
124
+ 'scheme' => 'fcm',
129
125
  ])->first();
130
126
  }
131
127
 
@@ -140,7 +136,7 @@ class StorefrontOrderDriverAssigned extends Notification
140
136
 
141
137
  public function configureFcm($notificationChannel)
142
138
  {
143
- $config = (array) $notificationChannel->config;
139
+ $config = (array) $notificationChannel->config;
144
140
  $fcmConfig = config('firebase.projects.app');
145
141
 
146
142
  // set credentials
@@ -157,7 +153,6 @@ class StorefrontOrderDriverAssigned extends Notification
157
153
  /**
158
154
  * Get the apns message representation of the notification.
159
155
  *
160
- * @param mixed $notifiable
161
156
  * @return array
162
157
  */
163
158
  public function toApn($notifiable)
@@ -167,13 +162,13 @@ class StorefrontOrderDriverAssigned extends Notification
167
162
  if ($this->order->hasMeta('storefront_notification_channel')) {
168
163
  $notificationChannel = NotificationChannel::where([
169
164
  'owner_uuid' => $about->uuid,
170
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
171
- 'scheme' => 'apn'
165
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
166
+ 'scheme' => 'apn',
172
167
  ])->first();
173
168
  } else {
174
169
  $notificationChannel = NotificationChannel::where([
175
170
  'owner_uuid' => $about->uuid,
176
- 'scheme' => 'apn'
171
+ 'scheme' => 'apn',
177
172
  ])->first();
178
173
  }
179
174
 
@@ -181,7 +176,7 @@ class StorefrontOrderDriverAssigned extends Notification
181
176
 
182
177
  try {
183
178
  $channelClient = new PushOkClient(PuskOkToken::create($config));
184
- } catch (Exception $e) {
179
+ } catch (\Exception $e) {
185
180
  // stop silently
186
181
  return;
187
182
  }
@@ -2,27 +2,26 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Notifications;
4
4
 
5
- use Exception;
6
5
  use Fleetbase\FleetOps\Models\Order;
6
+ use Fleetbase\FleetOps\Support\Utils;
7
7
  use Fleetbase\Storefront\Models\NotificationChannel;
8
8
  use Fleetbase\Storefront\Support\Storefront;
9
- use Fleetbase\FleetOps\Support\Utils;
10
9
  // use Fleetbase\FleetOps\Support\Utils;
11
10
  use Illuminate\Bus\Queueable;
12
11
  // use Illuminate\Contracts\Queue\ShouldQueue;
13
12
  use Illuminate\Notifications\Messages\MailMessage;
14
13
  use Illuminate\Notifications\Notification;
15
- use NotificationChannels\Fcm\FcmChannel;
16
- use NotificationChannels\Fcm\FcmMessage;
17
14
  use NotificationChannels\Apn\ApnChannel;
18
15
  use NotificationChannels\Apn\ApnMessage;
16
+ use NotificationChannels\Fcm\FcmChannel;
17
+ use NotificationChannels\Fcm\FcmMessage;
19
18
  use NotificationChannels\Fcm\Resources\AndroidConfig;
20
19
  use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
21
20
  use NotificationChannels\Fcm\Resources\AndroidNotification;
22
21
  use NotificationChannels\Fcm\Resources\ApnsConfig;
23
22
  use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
24
- use Pushok\Client as PushOkClient;
25
23
  use Pushok\AuthProvider\Token as PuskOkToken;
24
+ use Pushok\Client as PushOkClient;
26
25
 
27
26
  class StorefrontOrderEnroute extends Notification
28
27
  {
@@ -35,14 +34,13 @@ class StorefrontOrderEnroute extends Notification
35
34
  */
36
35
  public function __construct(Order $order)
37
36
  {
38
- $this->order = $order->setRelations([]);
37
+ $this->order = $order->setRelations([]);
39
38
  $this->storefront = Storefront::findAbout($this->order->getMeta('storefront_id'));
40
39
  }
41
40
 
42
41
  /**
43
42
  * Get the notification's delivery channels.
44
43
  *
45
- * @param mixed $notifiable
46
44
  * @return array
47
45
  */
48
46
  public function via($notifiable)
@@ -70,12 +68,11 @@ class StorefrontOrderEnroute extends Notification
70
68
  /**
71
69
  * Get the mail representation of the notification.
72
70
  *
73
- * @param mixed $notifiable
74
71
  * @return \Illuminate\Notifications\Messages\MailMessage
75
72
  */
76
73
  public function toMail($notifiable)
77
74
  {
78
- $message = (new MailMessage)
75
+ $message = (new MailMessage())
79
76
  ->subject('Your order from ' . $this->storefront->name . ' is on the way!')
80
77
  ->line('Your order from ' . $this->storefront->name . ' has been picked up, we will update you when your order is nearby');
81
78
 
@@ -87,7 +84,6 @@ class StorefrontOrderEnroute extends Notification
87
84
  /**
88
85
  * Get the firebase cloud message representation of the notification.
89
86
  *
90
- * @param mixed $notifiable
91
87
  * @return array
92
88
  */
93
89
  public function toFcm($notifiable)
@@ -118,13 +114,13 @@ class StorefrontOrderEnroute extends Notification
118
114
  if ($this->order->hasMeta('storefront_notification_channel')) {
119
115
  $notificationChannel = NotificationChannel::where([
120
116
  'owner_uuid' => $about->uuid,
121
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
122
- 'scheme' => 'fcm'
117
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
118
+ 'scheme' => 'fcm',
123
119
  ])->first();
124
120
  } else {
125
121
  $notificationChannel = NotificationChannel::where([
126
122
  'owner_uuid' => $about->uuid,
127
- 'scheme' => 'fcm'
123
+ 'scheme' => 'fcm',
128
124
  ])->first();
129
125
  }
130
126
 
@@ -139,7 +135,7 @@ class StorefrontOrderEnroute extends Notification
139
135
 
140
136
  public function configureFcm($notificationChannel)
141
137
  {
142
- $config = (array) $notificationChannel->config;
138
+ $config = (array) $notificationChannel->config;
143
139
  $fcmConfig = config('firebase.projects.app');
144
140
 
145
141
  // set credentials
@@ -156,7 +152,6 @@ class StorefrontOrderEnroute extends Notification
156
152
  /**
157
153
  * Get the apns message representation of the notification.
158
154
  *
159
- * @param mixed $notifiable
160
155
  * @return array
161
156
  */
162
157
  public function toApn($notifiable)
@@ -166,13 +161,13 @@ class StorefrontOrderEnroute extends Notification
166
161
  if ($this->order->hasMeta('storefront_notification_channel')) {
167
162
  $notificationChannel = NotificationChannel::where([
168
163
  'owner_uuid' => $about->uuid,
169
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
170
- 'scheme' => 'apn'
164
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
165
+ 'scheme' => 'apn',
171
166
  ])->first();
172
167
  } else {
173
168
  $notificationChannel = NotificationChannel::where([
174
169
  'owner_uuid' => $about->uuid,
175
- 'scheme' => 'apn'
170
+ 'scheme' => 'apn',
176
171
  ])->first();
177
172
  }
178
173
 
@@ -180,7 +175,7 @@ class StorefrontOrderEnroute extends Notification
180
175
 
181
176
  try {
182
177
  $channelClient = new PushOkClient(PuskOkToken::create($config));
183
- } catch (Exception $e) {
178
+ } catch (\Exception $e) {
184
179
  // stop silently
185
180
  return;
186
181
  }
@@ -2,27 +2,26 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Notifications;
4
4
 
5
- use Exception;
6
5
  use Fleetbase\FleetOps\Models\Order;
6
+ use Fleetbase\FleetOps\Support\Utils;
7
7
  use Fleetbase\Storefront\Models\NotificationChannel;
8
8
  use Fleetbase\Storefront\Support\Storefront;
9
- use Fleetbase\FleetOps\Support\Utils;
10
9
  // use Fleetbase\FleetOps\Support\Utils;
11
10
  use Illuminate\Bus\Queueable;
12
11
  // use Illuminate\Contracts\Queue\ShouldQueue;
13
12
  use Illuminate\Notifications\Messages\MailMessage;
14
13
  use Illuminate\Notifications\Notification;
15
- use NotificationChannels\Fcm\FcmChannel;
16
- use NotificationChannels\Fcm\FcmMessage;
17
14
  use NotificationChannels\Apn\ApnChannel;
18
15
  use NotificationChannels\Apn\ApnMessage;
16
+ use NotificationChannels\Fcm\FcmChannel;
17
+ use NotificationChannels\Fcm\FcmMessage;
19
18
  use NotificationChannels\Fcm\Resources\AndroidConfig;
20
19
  use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
21
20
  use NotificationChannels\Fcm\Resources\AndroidNotification;
22
21
  use NotificationChannels\Fcm\Resources\ApnsConfig;
23
22
  use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
24
- use Pushok\Client as PushOkClient;
25
23
  use Pushok\AuthProvider\Token as PuskOkToken;
24
+ use Pushok\Client as PushOkClient;
26
25
 
27
26
  class StorefrontOrderNearby extends Notification
28
27
  {
@@ -35,16 +34,15 @@ class StorefrontOrderNearby extends Notification
35
34
  */
36
35
  public function __construct(Order $order, $distance = 0, $time = 0)
37
36
  {
38
- $this->order = $order->setRelations([]);
37
+ $this->order = $order->setRelations([]);
39
38
  $this->storefront = Storefront::findAbout($this->order->getMeta('storefront_id'));
40
- $this->distance = $distance;
41
- $this->time = $time;
39
+ $this->distance = $distance;
40
+ $this->time = $time;
42
41
  }
43
42
 
44
43
  /**
45
44
  * Get the notification's delivery channels.
46
45
  *
47
- * @param mixed $notifiable
48
46
  * @return array
49
47
  */
50
48
  public function via($notifiable)
@@ -72,12 +70,11 @@ class StorefrontOrderNearby extends Notification
72
70
  /**
73
71
  * Get the mail representation of the notification.
74
72
  *
75
- * @param mixed $notifiable
76
73
  * @return \Illuminate\Notifications\Messages\MailMessage
77
74
  */
78
75
  public function toMail($notifiable)
79
76
  {
80
- $message = (new MailMessage)
77
+ $message = (new MailMessage())
81
78
  ->subject('Your order is nearby')
82
79
  ->line('Your order from ' . $this->storefront->name . ' is reaching in ' . Utils::formatSeconds($this->time));
83
80
 
@@ -89,7 +86,6 @@ class StorefrontOrderNearby extends Notification
89
86
  /**
90
87
  * Get the firebase cloud message representation of the notification.
91
88
  *
92
- * @param mixed $notifiable
93
89
  * @return array
94
90
  */
95
91
  public function toFcm($notifiable)
@@ -120,13 +116,13 @@ class StorefrontOrderNearby extends Notification
120
116
  if ($this->order->hasMeta('storefront_notification_channel')) {
121
117
  $notificationChannel = NotificationChannel::where([
122
118
  'owner_uuid' => $about->uuid,
123
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
124
- 'scheme' => 'fcm'
119
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
120
+ 'scheme' => 'fcm',
125
121
  ])->first();
126
122
  } else {
127
123
  $notificationChannel = NotificationChannel::where([
128
124
  'owner_uuid' => $about->uuid,
129
- 'scheme' => 'fcm'
125
+ 'scheme' => 'fcm',
130
126
  ])->first();
131
127
  }
132
128
 
@@ -141,7 +137,7 @@ class StorefrontOrderNearby extends Notification
141
137
 
142
138
  public function configureFcm($notificationChannel)
143
139
  {
144
- $config = (array) $notificationChannel->config;
140
+ $config = (array) $notificationChannel->config;
145
141
  $fcmConfig = config('firebase.projects.app');
146
142
 
147
143
  // set credentials
@@ -158,7 +154,6 @@ class StorefrontOrderNearby extends Notification
158
154
  /**
159
155
  * Get the apns message representation of the notification.
160
156
  *
161
- * @param mixed $notifiable
162
157
  * @return array
163
158
  */
164
159
  public function toApn($notifiable)
@@ -168,13 +163,13 @@ class StorefrontOrderNearby extends Notification
168
163
  if ($this->order->hasMeta('storefront_notification_channel')) {
169
164
  $notificationChannel = NotificationChannel::where([
170
165
  'owner_uuid' => $about->uuid,
171
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
172
- 'scheme' => 'apn'
166
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
167
+ 'scheme' => 'apn',
173
168
  ])->first();
174
169
  } else {
175
170
  $notificationChannel = NotificationChannel::where([
176
171
  'owner_uuid' => $about->uuid,
177
- 'scheme' => 'apn'
172
+ 'scheme' => 'apn',
178
173
  ])->first();
179
174
  }
180
175
 
@@ -182,7 +177,7 @@ class StorefrontOrderNearby extends Notification
182
177
 
183
178
  try {
184
179
  $channelClient = new PushOkClient(PuskOkToken::create($config));
185
- } catch (Exception $e) {
180
+ } catch (\Exception $e) {
186
181
  // stop silently
187
182
  return;
188
183
  }