@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
@@ -3,17 +3,17 @@
3
3
  namespace Fleetbase\Storefront\Models;
4
4
 
5
5
  use Fleetbase\Casts\Json;
6
+ use Fleetbase\FleetOps\Models\Place;
6
7
  use Fleetbase\Models\Category;
7
- use Fleetbase\Models\User;
8
8
  use Fleetbase\Models\Company;
9
9
  use Fleetbase\Models\File;
10
- use Fleetbase\FleetOps\Models\Place;
10
+ use Fleetbase\Models\User;
11
11
  use Fleetbase\Support\Utils as FleetbaseUtils;
12
+ use Fleetbase\Traits\HasApiModelBehavior;
12
13
  use Fleetbase\Traits\HasMetaAttributes;
13
14
  use Fleetbase\Traits\HasOptionsAttributes;
14
- use Fleetbase\Traits\HasUuid;
15
- use Fleetbase\Traits\HasApiModelBehavior;
16
15
  use Fleetbase\Traits\HasPublicid;
16
+ use Fleetbase\Traits\HasUuid;
17
17
  use Fleetbase\Traits\Searchable;
18
18
  use Illuminate\Support\Carbon;
19
19
  use Illuminate\Support\Str;
@@ -22,10 +22,16 @@ use Spatie\Sluggable\SlugOptions;
22
22
 
23
23
  class Store extends StorefrontModel
24
24
  {
25
- use HasUuid, HasPublicid, HasApiModelBehavior, HasOptionsAttributes, HasMetaAttributes, HasSlug, Searchable;
25
+ use HasUuid;
26
+ use HasPublicid;
27
+ use HasApiModelBehavior;
28
+ use HasOptionsAttributes;
29
+ use HasMetaAttributes;
30
+ use HasSlug;
31
+ use Searchable;
26
32
 
27
33
  /**
28
- * The type of public Id to generate
34
+ * The type of public Id to generate.
29
35
  *
30
36
  * @var string
31
37
  */
@@ -39,7 +45,7 @@ class Store extends StorefrontModel
39
45
  protected $table = 'stores';
40
46
 
41
47
  /**
42
- * These attributes that can be queried
48
+ * These attributes that can be queried.
43
49
  *
44
50
  * @var array
45
51
  */
@@ -58,17 +64,17 @@ class Store extends StorefrontModel
58
64
  * @var array
59
65
  */
60
66
  protected $casts = [
61
- 'options' => Json::class,
62
- 'meta' => Json::class,
63
- 'translations' => Json::class,
64
- 'alertable' => Json::class,
65
- 'tags' => 'array',
67
+ 'options' => Json::class,
68
+ 'meta' => Json::class,
69
+ 'translations' => Json::class,
70
+ 'alertable' => Json::class,
71
+ 'tags' => 'array',
66
72
  'require_account' => 'boolean',
67
- 'online' => 'boolean'
73
+ 'online' => 'boolean',
68
74
  ];
69
75
 
70
76
  /**
71
- * Dynamic attributes that are appended to object
77
+ * Dynamic attributes that are appended to object.
72
78
  *
73
79
  * @var array
74
80
  */
@@ -82,7 +88,7 @@ class Store extends StorefrontModel
82
88
  protected $hidden = ['logo', 'backdrop', 'files'];
83
89
 
84
90
  /**
85
- * Attributes that is filterable on this model
91
+ * Attributes that is filterable on this model.
86
92
  *
87
93
  * @var array
88
94
  */
@@ -156,7 +162,7 @@ class Store extends StorefrontModel
156
162
  'type',
157
163
  'caption',
158
164
  'created_at',
159
- 'updated_at'
165
+ 'updated_at',
160
166
  ]
161
167
  )->where('type', 'storefront_store_media');
162
168
  }
@@ -302,8 +308,9 @@ class Store extends StorefrontModel
302
308
  /**
303
309
  * Retrieves the category of the store belonging to the specified network using the network id.
304
310
  *
305
- * @param string $id The ID of the network for which the category is to be retrieved.
306
- * @return \Fleetbase\Models\Category|null The category of the store in the given network, or null if the store does not belong to the network.
311
+ * @param string $id the ID of the network for which the category is to be retrieved
312
+ *
313
+ * @return \Fleetbase\Models\Category|null the category of the store in the given network, or null if the store does not belong to the network
307
314
  */
308
315
  public function getNetworkCategoryUsingId(?string $id)
309
316
  {
@@ -325,8 +332,9 @@ class Store extends StorefrontModel
325
332
  /**
326
333
  * Retrieves the category of the store belonging to the specified network.
327
334
  *
328
- * @param \Fleetbase\Storefront\Models\Network $network The network for which the category is to be retrieved.
329
- * @return \Fleetbase\Models\Category|null The category of the store in the given network, or null if the store does not belong to the network.
335
+ * @param \Fleetbase\Storefront\Models\Network $network the network for which the category is to be retrieved
336
+ *
337
+ * @return \Fleetbase\Models\Category|null the category of the store in the given network, or null if the store does not belong to the network
330
338
  */
331
339
  public function getNetworkCategory(Network $network)
332
340
  {
@@ -347,18 +355,12 @@ class Store extends StorefrontModel
347
355
  }
348
356
 
349
357
  /**
350
- *'Create a new product category for this store record
358
+ *'Create a new product category for this store record.
351
359
  *
352
- * @param string $name
353
- * @param string $description
354
- * @param array|null $meta
355
- * @param array|null $translations
356
- * @param Category|null $parent
357
360
  * @param File|string|null $icon
358
- * @param string $iconColor
359
- * @return Category
361
+ * @param string $iconColor
360
362
  */
361
- public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
363
+ public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
362
364
  {
363
365
  $iconFile = null;
364
366
  $iconName = null;
@@ -373,35 +375,29 @@ class Store extends StorefrontModel
373
375
 
374
376
  return Category::create(
375
377
  [
376
- 'company_uuid' => $this->company_uuid,
377
- 'owner_uuid' => $this->uuid,
378
- 'owner_type' => FleetbaseUtils::getMutationType('storefront:store'),
379
- 'parent_uuid' => $parent instanceof Category ? $parent->uuid : null,
378
+ 'company_uuid' => $this->company_uuid,
379
+ 'owner_uuid' => $this->uuid,
380
+ 'owner_type' => FleetbaseUtils::getMutationType('storefront:store'),
381
+ 'parent_uuid' => $parent instanceof Category ? $parent->uuid : null,
380
382
  'icon_file_uuid' => $iconFile instanceof File ? $iconFile->uuid : null,
381
- 'for' => 'storefront_product',
382
- 'name' => $name,
383
- 'description' => $description,
384
- 'translations' => $translations,
385
- 'meta' => $meta,
386
- 'icon' => $iconName,
387
- 'icon_color' => $iconColor
383
+ 'for' => 'storefront_product',
384
+ 'name' => $name,
385
+ 'description' => $description,
386
+ 'translations' => $translations,
387
+ 'meta' => $meta,
388
+ 'icon' => $iconName,
389
+ 'icon_color' => $iconColor,
388
390
  ]
389
391
  );
390
392
  }
391
393
 
392
394
  /**
393
- * Create a new product category if it doesn't already exists for this store record
395
+ * Create a new product category if it doesn't already exists for this store record.
394
396
  *
395
- * @param string $name
396
- * @param string $description
397
- * @param array|null $meta
398
- * @param array|null $translations
399
- * @param Category|null $parent
400
397
  * @param File|string|null $icon
401
- * @param string $iconColor
402
- * @return Category
398
+ * @param string $iconColor
403
399
  */
404
- public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
400
+ public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
405
401
  {
406
402
  $existingCategory = Category::where(['company_uuid' => $this->company_uuid, 'owner_uuid' => $this->uuid, 'name' => $name])->first();
407
403
 
@@ -414,42 +410,30 @@ class Store extends StorefrontModel
414
410
 
415
411
  /**
416
412
  * Creates a new product in the store.
417
- *
418
- * @param string $name
419
- * @param string $description
420
- * @param array $tags
421
- * @param Category|null $category
422
- * @param File|null $image
423
- * @param User|null $createdBy
424
- * @param string $sku
425
- * @param integer $price
426
- * @param string $status
427
- * @param array $options
428
- * @return Product
429
- */
430
- public function createProduct(string $name, string $description, array $tags = [], ?Category $category = null, ?File $image = null, ?User $createdBy = null, string $sku = '', int $price = 0, string $status = 'available', array $options = []): Product
413
+ */
414
+ public function createProduct(string $name, string $description, array $tags = [], Category $category = null, File $image = null, User $createdBy = null, string $sku = '', int $price = 0, string $status = 'available', array $options = []): Product
431
415
  {
432
416
  return Product::create(
433
417
  [
434
- 'company_uuid' => $this->company_uuid,
418
+ 'company_uuid' => $this->company_uuid,
435
419
  'primary_image_uuid' => $image instanceof File ? $image->uuid : null,
436
- 'created_by_uuid' => $createdBy instanceof User ? $createdBy->uuid : null,
437
- 'store_uuid' => $this->uuid,
438
- 'category_uuid' => $category instanceof Category ? $category->uuid : null,
439
- 'name' => $name,
440
- 'description' => $description,
441
- 'tags' => $tags,
442
- 'sku' => $sku,
443
- 'price' => $price,
444
- 'sale_price' => isset($options['sale_price']) ? $options['sale_price'] : null,
445
- 'currency' => $this->currency,
446
- 'is_service' => isset($options['is_service']) ? $options['is_service'] : false,
447
- 'is_bookable' => isset($options['is_bookable']) ? $options['is_bookable'] : false,
448
- 'is_available' => isset($options['is_available']) ? $options['is_available'] : true,
449
- 'is_on_sale' => isset($options['is_on_sale']) ? $options['is_on_sale'] : false,
450
- 'is_recommended' => isset($options['is_recommended']) ? $options['is_recommended'] : false,
451
- 'can_pickup' => isset($options['can_pickup']) ? $options['can_pickup'] : false,
452
- 'status' => $status
420
+ 'created_by_uuid' => $createdBy instanceof User ? $createdBy->uuid : null,
421
+ 'store_uuid' => $this->uuid,
422
+ 'category_uuid' => $category instanceof Category ? $category->uuid : null,
423
+ 'name' => $name,
424
+ 'description' => $description,
425
+ 'tags' => $tags,
426
+ 'sku' => $sku,
427
+ 'price' => $price,
428
+ 'sale_price' => isset($options['sale_price']) ? $options['sale_price'] : null,
429
+ 'currency' => $this->currency,
430
+ 'is_service' => isset($options['is_service']) ? $options['is_service'] : false,
431
+ 'is_bookable' => isset($options['is_bookable']) ? $options['is_bookable'] : false,
432
+ 'is_available' => isset($options['is_available']) ? $options['is_available'] : true,
433
+ 'is_on_sale' => isset($options['is_on_sale']) ? $options['is_on_sale'] : false,
434
+ 'is_recommended' => isset($options['is_recommended']) ? $options['is_recommended'] : false,
435
+ 'can_pickup' => isset($options['can_pickup']) ? $options['can_pickup'] : false,
436
+ 'status' => $status,
453
437
  ]
454
438
  );
455
439
  }
@@ -465,10 +449,10 @@ class Store extends StorefrontModel
465
449
  if ($place instanceof Place) {
466
450
  return StoreLocation::create(
467
451
  [
468
- 'store_uuid' => $this->uuid,
452
+ 'store_uuid' => $this->uuid,
469
453
  'created_by_uuid' => $createdBy instanceof User ? $createdBy->uuid : null,
470
- 'place_uuid' => $place->uuid,
471
- 'name' => $name
454
+ 'place_uuid' => $place->uuid,
455
+ 'name' => $name,
472
456
  ]
473
457
  );
474
458
  }
@@ -2,12 +2,13 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Models;
4
4
 
5
- use Fleetbase\Traits\HasUuid;
6
5
  use Fleetbase\Traits\HasApiModelBehavior;
6
+ use Fleetbase\Traits\HasUuid;
7
7
 
8
8
  class StoreHour extends StorefrontModel
9
9
  {
10
- use HasUuid, HasApiModelBehavior;
10
+ use HasUuid;
11
+ use HasApiModelBehavior;
11
12
 
12
13
  /**
13
14
  * The database table used by the model.
@@ -17,7 +18,7 @@ class StoreHour extends StorefrontModel
17
18
  protected $table = 'store_hours';
18
19
 
19
20
  /**
20
- * These attributes that can be queried
21
+ * These attributes that can be queried.
21
22
  *
22
23
  * @var array
23
24
  */
@@ -32,7 +33,7 @@ class StoreHour extends StorefrontModel
32
33
  'store_location_uuid',
33
34
  'day_of_week',
34
35
  'start',
35
- 'end'
36
+ 'end',
36
37
  ];
37
38
 
38
39
  /**
@@ -43,7 +44,7 @@ class StoreHour extends StorefrontModel
43
44
  protected $casts = [];
44
45
 
45
46
  /**
46
- * Dynamic attributes that are appended to object
47
+ * Dynamic attributes that are appended to object.
47
48
  *
48
49
  * @var array
49
50
  */
@@ -2,19 +2,22 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Models;
4
4
 
5
- use Fleetbase\Models\User;
6
5
  use Fleetbase\FleetOps\Models\Place;
7
- use Fleetbase\Traits\HasUuid;
6
+ use Fleetbase\Models\User;
8
7
  use Fleetbase\Traits\HasApiModelBehavior;
9
8
  use Fleetbase\Traits\HasPublicid;
9
+ use Fleetbase\Traits\HasUuid;
10
10
  use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
11
11
 
12
12
  class StoreLocation extends StorefrontModel
13
13
  {
14
- use HasUuid, HasPublicid, HasApiModelBehavior, SpatialTrait;
14
+ use HasUuid;
15
+ use HasPublicid;
16
+ use HasApiModelBehavior;
17
+ use SpatialTrait;
15
18
 
16
19
  /**
17
- * The type of public Id to generate
20
+ * The type of public Id to generate.
18
21
  *
19
22
  * @var string
20
23
  */
@@ -28,7 +31,7 @@ class StoreLocation extends StorefrontModel
28
31
  protected $table = 'store_locations';
29
32
 
30
33
  /**
31
- * These attributes that can be queried
34
+ * These attributes that can be queried.
32
35
  *
33
36
  * @var array
34
37
  */
@@ -51,7 +54,7 @@ class StoreLocation extends StorefrontModel
51
54
  'store_uuid',
52
55
  'created_by_uuid',
53
56
  'place_uuid',
54
- 'name'
57
+ 'name',
55
58
  ];
56
59
 
57
60
  /**
@@ -62,7 +65,7 @@ class StoreLocation extends StorefrontModel
62
65
  protected $casts = [];
63
66
 
64
67
  /**
65
- * Dynamic attributes that are appended to object
68
+ * Dynamic attributes that are appended to object.
66
69
  *
67
70
  * @var array
68
71
  */
@@ -108,7 +111,8 @@ class StoreLocation extends StorefrontModel
108
111
  }
109
112
 
110
113
  /**
111
- * Get address for places
114
+ * Get address for places.
115
+ *
112
116
  * @return string
113
117
  */
114
118
  public function getAddressAttribute()
@@ -9,7 +9,7 @@ class StorefrontModel extends Model
9
9
  /**
10
10
  * Create a new instance of the model.
11
11
  *
12
- * @param array $attributes The attributes to set on the model.
12
+ * @param array $attributes the attributes to set on the model
13
13
  *
14
14
  * @return void
15
15
  */
@@ -2,16 +2,18 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Models;
4
4
 
5
- use Fleetbase\Traits\HasUuid;
6
5
  use Fleetbase\Traits\HasApiModelBehavior;
7
6
  use Fleetbase\Traits\HasPublicid;
7
+ use Fleetbase\Traits\HasUuid;
8
8
 
9
9
  class Vote extends StorefrontModel
10
10
  {
11
- use HasUuid, HasPublicid, HasApiModelBehavior;
11
+ use HasUuid;
12
+ use HasPublicid;
13
+ use HasApiModelBehavior;
12
14
 
13
15
  /**
14
- * The type of public Id to generate
16
+ * The type of public Id to generate.
15
17
  *
16
18
  * @var string
17
19
  */
@@ -25,7 +27,7 @@ class Vote extends StorefrontModel
25
27
  protected $table = 'votes';
26
28
 
27
29
  /**
28
- * These attributes that can be queried
30
+ * These attributes that can be queried.
29
31
  *
30
32
  * @var array
31
33
  */
@@ -41,7 +43,7 @@ class Vote extends StorefrontModel
41
43
  'customer_uuid',
42
44
  'subject_uuid',
43
45
  'subject_type',
44
- 'type'
46
+ 'type',
45
47
  ];
46
48
 
47
49
  /**
@@ -52,7 +54,7 @@ class Vote extends StorefrontModel
52
54
  protected $casts = [];
53
55
 
54
56
  /**
55
- * Dynamic attributes that are appended to object
57
+ * Dynamic attributes that are appended to object.
56
58
  *
57
59
  * @var array
58
60
  */
@@ -2,25 +2,24 @@
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\Notifications\Messages\MailMessage;
12
11
  use Illuminate\Notifications\Notification;
13
- use NotificationChannels\Fcm\FcmChannel;
14
- use NotificationChannels\Fcm\FcmMessage;
15
12
  use NotificationChannels\Apn\ApnChannel;
16
13
  use NotificationChannels\Apn\ApnMessage;
14
+ use NotificationChannels\Fcm\FcmChannel;
15
+ use NotificationChannels\Fcm\FcmMessage;
17
16
  use NotificationChannels\Fcm\Resources\AndroidConfig;
18
17
  use NotificationChannels\Fcm\Resources\AndroidFcmOptions;
19
18
  use NotificationChannels\Fcm\Resources\AndroidNotification;
20
19
  use NotificationChannels\Fcm\Resources\ApnsConfig;
21
20
  use NotificationChannels\Fcm\Resources\ApnsFcmOptions;
22
- use Pushok\Client as PushOkClient;
23
21
  use Pushok\AuthProvider\Token as PuskOkToken;
22
+ use Pushok\Client as PushOkClient;
24
23
 
25
24
  class StorefrontOrderCanceled extends Notification
26
25
  {
@@ -47,14 +46,13 @@ class StorefrontOrderCanceled extends Notification
47
46
  */
48
47
  public function __construct(Order $order)
49
48
  {
50
- $this->order = $order->setRelations([]);
49
+ $this->order = $order->setRelations([]);
51
50
  $this->storefront = Storefront::findAbout($this->order->getMeta('storefront_id'));
52
51
  }
53
52
 
54
53
  /**
55
54
  * Get the notification's delivery channels.
56
55
  *
57
- * @param mixed $notifiable
58
56
  * @return array
59
57
  */
60
58
  public function via($notifiable)
@@ -65,12 +63,11 @@ class StorefrontOrderCanceled extends Notification
65
63
  /**
66
64
  * Get the mail representation of the notification.
67
65
  *
68
- * @param mixed $notifiable
69
66
  * @return \Illuminate\Notifications\Messages\MailMessage
70
67
  */
71
68
  public function toMail($notifiable)
72
69
  {
73
- $message = (new MailMessage)
70
+ $message = (new MailMessage())
74
71
  ->subject('Your order from ' . $this->storefront->name . ' was canceled')
75
72
  ->line('Your order from ' . $this->storefront->name . ' has been canceled, if your card has been charged you will be refunded.')
76
73
  ->line('No further action is necessary.');
@@ -83,7 +80,6 @@ class StorefrontOrderCanceled extends Notification
83
80
  /**
84
81
  * Get the firebase cloud message representation of the notification.
85
82
  *
86
- * @param mixed $notifiable
87
83
  * @return array
88
84
  */
89
85
  public function toFcm($notifiable)
@@ -110,7 +106,6 @@ class StorefrontOrderCanceled extends Notification
110
106
  /**
111
107
  * Get the apns message representation of the notification.
112
108
  *
113
- * @param mixed $notifiable
114
109
  * @return array
115
110
  */
116
111
  public function toApn($notifiable)
@@ -120,13 +115,13 @@ class StorefrontOrderCanceled extends Notification
120
115
  if ($this->order->hasMeta('storefront_notification_channel')) {
121
116
  $notificationChannel = NotificationChannel::where([
122
117
  'owner_uuid' => $about->uuid,
123
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
124
- 'scheme' => 'apn'
118
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
119
+ 'scheme' => 'apn',
125
120
  ])->first();
126
121
  } else {
127
122
  $notificationChannel = NotificationChannel::where([
128
123
  'owner_uuid' => $about->uuid,
129
- 'scheme' => 'apn'
124
+ 'scheme' => 'apn',
130
125
  ])->first();
131
126
  }
132
127
 
@@ -134,8 +129,9 @@ class StorefrontOrderCanceled extends Notification
134
129
 
135
130
  try {
136
131
  $channelClient = new PushOkClient(PuskOkToken::create($config));
137
- } catch (Exception $e) {
132
+ } catch (\Exception $e) {
138
133
  app('sentry')->captureException($e);
134
+
139
135
  return;
140
136
  }
141
137
 
@@ -159,13 +155,13 @@ class StorefrontOrderCanceled extends Notification
159
155
  if ($this->order->hasMeta('storefront_notification_channel')) {
160
156
  $notificationChannel = NotificationChannel::where([
161
157
  'owner_uuid' => $about->uuid,
162
- 'app_key' => $this->order->getMeta('storefront_notification_channel'),
163
- 'scheme' => 'fcm'
158
+ 'app_key' => $this->order->getMeta('storefront_notification_channel'),
159
+ 'scheme' => 'fcm',
164
160
  ])->first();
165
161
  } else {
166
162
  $notificationChannel = NotificationChannel::where([
167
163
  'owner_uuid' => $about->uuid,
168
- 'scheme' => 'fcm'
164
+ 'scheme' => 'fcm',
169
165
  ])->first();
170
166
  }
171
167
 
@@ -180,7 +176,7 @@ class StorefrontOrderCanceled extends Notification
180
176
 
181
177
  public function configureFcm($notificationChannel)
182
178
  {
183
- $config = (array) $notificationChannel->config;
179
+ $config = (array) $notificationChannel->config;
184
180
  $fcmConfig = config('firebase.projects.app');
185
181
 
186
182
  // set credentials