@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.
- package/README.md +4 -4
- package/addon/components/modals/import-products.hbs +1 -1
- package/addon/components/schedule-manager.hbs +2 -2
- package/addon/components/widget/customers.hbs +1 -1
- package/addon/components/widget/customers.js +7 -4
- package/addon/components/widget/orders.js +4 -0
- package/addon/controllers/base-controller.js +31 -0
- package/addon/controllers/networks/index/network.js +2 -2
- package/addon/controllers/networks/index.js +3 -2
- package/addon/controllers/products/index/category/new.js +14 -11
- package/addon/controllers/products/index/category.js +2 -2
- package/addon/controllers/products/index/index.js +2 -2
- package/addon/controllers/products/index.js +2 -3
- package/addon/models/network.js +0 -1
- package/addon/models/product-addon-category.js +10 -1
- package/addon/models/product-variant.js +0 -2
- package/addon/models/product.js +35 -2
- package/addon/routes/customers/index.js +11 -1
- package/addon/routes/networks/index.js +9 -0
- package/addon/routes/orders/index.js +11 -1
- package/addon/routes/products/index.js +8 -2
- package/addon/serializers/product.js +16 -0
- package/addon/services/storefront.js +81 -0
- package/addon/templates/networks/index/network/stores.hbs +2 -2
- package/addon/templates/networks/index/network.hbs +1 -1
- package/addon/templates/products/index/category/new.hbs +3 -3
- package/addon/templates/products/index/category.hbs +20 -3
- package/app/controllers/base-controller.js +1 -0
- package/assets/sounds/storefront_order_alert.mp3 +0 -0
- package/composer.json +3 -3
- package/config/environment.js +11 -1
- package/extension.json +1 -1
- package/index.js +15 -0
- package/package.json +132 -125
- package/server/src/Auth/Schemas/Storefront.php +31 -39
- package/server/src/Console/Commands/NotifyStorefrontOrderNearby.php +9 -11
- package/server/src/Expansions/ContactFilterExpansion.php +36 -0
- package/server/src/Expansions/EntityExpansion.php +12 -12
- package/server/src/Expansions/OrderFilterExpansion.php +31 -0
- package/server/src/Expansions/VendorFilterExpansion.php +36 -0
- package/server/src/Http/Controllers/ActionController.php +9 -11
- package/server/src/Http/Controllers/AddonCategoryController.php +1 -1
- package/server/src/Http/Controllers/CustomerController.php +1 -1
- package/server/src/Http/Controllers/GatewayController.php +1 -1
- package/server/src/Http/Controllers/MetricsController.php +17 -17
- package/server/src/Http/Controllers/NetworkController.php +16 -26
- package/server/src/Http/Controllers/NotificationChannelController.php +1 -1
- package/server/src/Http/Controllers/OrderController.php +18 -22
- package/server/src/Http/Controllers/ProductAddonCategoryController.php +1 -2
- package/server/src/Http/Controllers/ProductAddonController.php +1 -2
- package/server/src/Http/Controllers/ProductController.php +89 -44
- package/server/src/Http/Controllers/ProductHourController.php +1 -1
- package/server/src/Http/Controllers/ProductVariantController.php +1 -1
- package/server/src/Http/Controllers/ProductVariantOptionController.php +1 -1
- package/server/src/Http/Controllers/ReviewController.php +1 -1
- package/server/src/Http/Controllers/StoreController.php +1 -2
- package/server/src/Http/Controllers/StoreHourController.php +1 -1
- package/server/src/Http/Controllers/StoreLocationController.php +1 -1
- package/server/src/Http/Controllers/StorefrontController.php +0 -2
- package/server/src/Http/Controllers/VoteController.php +1 -1
- package/server/src/Http/Controllers/v1/CartController.php +16 -26
- package/server/src/Http/Controllers/v1/CategoryController.php +3 -4
- package/server/src/Http/Controllers/v1/CheckoutController.php +283 -286
- package/server/src/Http/Controllers/v1/CustomerController.php +54 -67
- package/server/src/Http/Controllers/v1/GatewayControllerController.php +0 -2
- package/server/src/Http/Controllers/v1/NetworkController.php +26 -23
- package/server/src/Http/Controllers/v1/PaymentMethodController.php +0 -2
- package/server/src/Http/Controllers/v1/ProductController.php +1 -4
- package/server/src/Http/Controllers/v1/ReviewController.php +31 -35
- package/server/src/Http/Controllers/v1/ServiceQuoteController.php +57 -53
- package/server/src/Http/Controllers/v1/StoreController.php +8 -16
- package/server/src/Http/Filter/AddonCategoryFilter.php +1 -1
- package/server/src/Http/Filter/OrderFilter.php +2 -2
- package/server/src/Http/Middleware/SetStorefrontSession.php +9 -20
- package/server/src/Http/Requests/AddStoreToNetworkCategory.php +3 -3
- package/server/src/Http/Requests/CreateCustomerRequest.php +5 -7
- package/server/src/Http/Requests/CreateReviewRequest.php +4 -5
- package/server/src/Http/Requests/GetServiceQuoteFromCart.php +2 -2
- package/server/src/Http/Requests/InitializeCheckoutRequest.php +5 -5
- package/server/src/Http/Requests/NetworkActionRequest.php +2 -2
- package/server/src/Http/Requests/VerifyCreateCustomerRequest.php +2 -2
- package/server/src/Http/Resources/Cart.php +20 -11
- package/server/src/Http/Resources/Category.php +12 -11
- package/server/src/Http/Resources/Customer.php +15 -14
- package/server/src/Http/Resources/Gateway.php +12 -11
- package/server/src/Http/Resources/Media.php +9 -8
- package/server/src/Http/Resources/Network.php +33 -28
- package/server/src/Http/Resources/Product.php +89 -81
- package/server/src/Http/Resources/Review.php +14 -13
- package/server/src/Http/Resources/ReviewCustomer.php +12 -11
- package/server/src/Http/Resources/Store.php +39 -33
- package/server/src/Http/Resources/StoreHour.php +9 -8
- package/server/src/Http/Resources/StoreLocation.php +9 -9
- package/server/src/Imports/ProductsImport.php +0 -2
- package/server/src/Jobs/DownloadProductImageUrl.php +7 -4
- package/server/src/Listeners/HandleOrderCompleted.php +2 -1
- package/server/src/Listeners/HandleOrderDispatched.php +2 -1
- package/server/src/Listeners/HandleOrderDriverAssigned.php +2 -1
- package/server/src/Listeners/HandleOrderStarted.php +4 -3
- package/server/src/Mail/StorefrontNetworkInvite.php +7 -6
- package/server/src/Models/AddonCategory.php +2 -4
- package/server/src/Models/Cart.php +117 -124
- package/server/src/Models/Checkout.php +14 -12
- package/server/src/Models/Customer.php +9 -9
- package/server/src/Models/Gateway.php +22 -22
- package/server/src/Models/Network.php +41 -52
- package/server/src/Models/NetworkStore.php +6 -5
- package/server/src/Models/NotificationChannel.php +11 -9
- package/server/src/Models/PaymentMethod.php +9 -7
- package/server/src/Models/Product.php +152 -30
- package/server/src/Models/ProductAddon.php +14 -11
- package/server/src/Models/ProductAddonCategory.php +9 -8
- package/server/src/Models/ProductHour.php +6 -5
- package/server/src/Models/ProductStoreLocation.php +7 -5
- package/server/src/Models/ProductVariant.php +15 -11
- package/server/src/Models/ProductVariantOption.php +12 -9
- package/server/src/Models/Review.php +9 -7
- package/server/src/Models/Store.php +68 -84
- package/server/src/Models/StoreHour.php +6 -5
- package/server/src/Models/StoreLocation.php +12 -8
- package/server/src/Models/StorefrontModel.php +1 -1
- package/server/src/Models/Vote.php +8 -6
- package/server/src/Notifications/StorefrontOrderCanceled.php +15 -19
- package/server/src/Notifications/StorefrontOrderCompleted.php +15 -19
- package/server/src/Notifications/StorefrontOrderCreated.php +31 -36
- package/server/src/Notifications/StorefrontOrderDriverAssigned.php +15 -20
- package/server/src/Notifications/StorefrontOrderEnroute.php +14 -19
- package/server/src/Notifications/StorefrontOrderNearby.php +16 -21
- package/server/src/Notifications/StorefrontOrderPreparing.php +15 -18
- package/server/src/Notifications/StorefrontOrderReadyForPickup.php +15 -18
- package/server/src/Observers/NetworkObserver.php +2 -3
- package/server/src/Observers/ProductObserver.php +17 -33
- package/server/src/Providers/EventServiceProvider.php +15 -4
- package/server/src/Providers/StorefrontServiceProvider.php +8 -10
- package/server/src/Support/Metrics.php +12 -12
- package/server/src/Support/OrderConfig.php +3 -2
- package/server/src/Support/QPay.php +22 -20
- package/server/src/Support/Storefront.php +18 -17
- package/server/src/routes.php +1 -1
- 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\
|
|
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
|
|
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'
|
|
62
|
-
'meta'
|
|
63
|
-
'translations'
|
|
64
|
-
'alertable'
|
|
65
|
-
'tags'
|
|
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'
|
|
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
|
|
306
|
-
*
|
|
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
|
|
329
|
-
*
|
|
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
|
|
359
|
-
* @return Category
|
|
361
|
+
* @param string $iconColor
|
|
360
362
|
*/
|
|
361
|
-
public function createCategory(string $name, string $description = '', ?array $meta = [],
|
|
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'
|
|
377
|
-
'owner_uuid'
|
|
378
|
-
'owner_type'
|
|
379
|
-
'parent_uuid'
|
|
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'
|
|
382
|
-
'name'
|
|
383
|
-
'description'
|
|
384
|
-
'translations'
|
|
385
|
-
'meta'
|
|
386
|
-
'icon'
|
|
387
|
-
'icon_color'
|
|
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
|
|
402
|
-
* @return Category
|
|
398
|
+
* @param string $iconColor
|
|
403
399
|
*/
|
|
404
|
-
public function createCategoryStrict(string $name, string $description = '', ?array $meta = [],
|
|
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
|
-
|
|
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'
|
|
418
|
+
'company_uuid' => $this->company_uuid,
|
|
435
419
|
'primary_image_uuid' => $image instanceof File ? $image->uuid : null,
|
|
436
|
-
'created_by_uuid'
|
|
437
|
-
'store_uuid'
|
|
438
|
-
'category_uuid'
|
|
439
|
-
'name'
|
|
440
|
-
'description'
|
|
441
|
-
'tags'
|
|
442
|
-
'sku'
|
|
443
|
-
'price'
|
|
444
|
-
'sale_price'
|
|
445
|
-
'currency'
|
|
446
|
-
'is_service'
|
|
447
|
-
'is_bookable'
|
|
448
|
-
'is_available'
|
|
449
|
-
'is_on_sale'
|
|
450
|
-
'is_recommended'
|
|
451
|
-
'can_pickup'
|
|
452
|
-
'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'
|
|
452
|
+
'store_uuid' => $this->uuid,
|
|
469
453
|
'created_by_uuid' => $createdBy instanceof User ? $createdBy->uuid : null,
|
|
470
|
-
'place_uuid'
|
|
471
|
-
'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
|
|
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\
|
|
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
|
|
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()
|
|
@@ -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
|
|
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
|
|
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'
|
|
124
|
-
'scheme'
|
|
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'
|
|
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'
|
|
163
|
-
'scheme'
|
|
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'
|
|
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
|
|
179
|
+
$config = (array) $notificationChannel->config;
|
|
184
180
|
$fcmConfig = config('firebase.projects.app');
|
|
185
181
|
|
|
186
182
|
// set credentials
|