@fleetbase/storefront-engine 0.3.4 → 0.3.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/addon/components/context-panel.hbs +5 -0
- package/addon/components/context-panel.js +6 -0
- package/addon/components/customer-panel/details.hbs +34 -0
- package/addon/components/customer-panel/details.js +3 -0
- package/addon/components/customer-panel/orders.hbs +140 -0
- package/addon/components/customer-panel/orders.js +78 -0
- package/addon/components/customer-panel.hbs +70 -0
- package/addon/components/customer-panel.js +171 -0
- package/addon/components/display-place.hbs +52 -0
- package/addon/components/display-place.js +11 -0
- package/addon/components/modals/manage-addons.hbs +15 -52
- package/addon/components/modals/manage-addons.js +93 -43
- package/addon/components/modals/select-addon-category.hbs +1 -1
- package/addon/components/order-panel/details.hbs +245 -0
- package/addon/components/order-panel/details.js +189 -0
- package/addon/components/order-panel.hbs +1 -0
- package/addon/components/order-panel.js +38 -0
- package/addon/components/storefront-order-summary.hbs +9 -2
- package/addon/components/widget/customers.hbs +3 -1
- package/addon/components/widget/customers.js +5 -0
- package/addon/components/widget/orders.js +8 -146
- package/addon/controllers/customers/index/view.js +43 -0
- package/addon/controllers/customers/index.js +10 -6
- package/addon/controllers/networks/index/network/customers.js +68 -2
- package/addon/controllers/networks/index/network/orders.js +324 -1
- package/addon/controllers/networks/index/network/stores.js +0 -2
- package/addon/controllers/orders/index/view.js +13 -0
- package/addon/controllers/orders/index.js +10 -7
- package/addon/controllers/products/index/category/edit.js +12 -16
- package/addon/controllers/products/index/category/new.js +40 -45
- package/addon/controllers/products/index.js +8 -2
- package/addon/helpers/avatar-url.js +9 -0
- package/addon/models/product-variant-option.js +8 -1
- package/addon/models/product-variant.js +12 -2
- package/addon/models/product.js +62 -0
- package/addon/routes/customers/index/view.js +14 -0
- package/addon/routes/networks/index/network/customers.js +29 -0
- package/addon/routes/networks/index/network/orders.js +5 -0
- package/addon/routes/networks/index.js +1 -1
- package/addon/routes/orders/index/view.js +22 -1
- package/addon/routes/products/index/category/edit.js +6 -0
- package/addon/routes/products/index/category/new.js +3 -1
- package/addon/routes.js +1 -0
- package/addon/serializers/product-variant-option.js +14 -0
- package/addon/serializers/product-variant.js +27 -0
- package/addon/serializers/product.js +26 -4
- package/addon/services/context-panel.js +210 -0
- package/addon/styles/storefront-engine.css +6 -0
- package/addon/templates/application.hbs +3 -1
- package/addon/templates/customers/index/view.hbs +1 -0
- package/addon/templates/networks/index/network/customers.hbs +18 -1
- package/addon/templates/networks/index/network/orders.hbs +18 -1
- package/addon/templates/networks/index/network.hbs +1 -1
- package/addon/templates/orders/index/view.hbs +1 -1
- package/addon/templates/products/index/category/new.hbs +12 -67
- package/app/components/context-panel.js +1 -0
- package/app/components/customer-panel/details.js +1 -0
- package/app/components/customer-panel/orders.js +1 -0
- package/app/components/customer-panel.js +1 -0
- package/app/components/display-place.js +1 -0
- package/app/components/order-panel/details.js +1 -0
- package/app/components/order-panel.js +1 -0
- package/app/controllers/customers/index/view.js +1 -0
- package/app/controllers/orders/index/view.js +1 -0
- package/app/helpers/avatar-url.js +1 -0
- package/app/routes/customers/index/view.js +1 -0
- package/app/serializers/product-variant-option.js +1 -0
- package/app/services/context-panel.js +1 -0
- package/app/templates/customers/index/view.js +1 -0
- package/composer.json +4 -4
- package/extension.json +1 -1
- package/package.json +9 -3
- package/server/seeders/OrderConfigSeeder.php +2 -249
- package/server/src/Http/Controllers/AddonCategoryController.php +90 -0
- package/server/src/Http/Controllers/v1/ReviewController.php +43 -52
- package/server/src/Http/Controllers/v1/ServiceQuoteController.php +7 -9
- package/server/src/Http/Resources/Network.php +34 -32
- package/server/src/Http/Resources/NotificationChannel.php +32 -0
- package/server/src/Http/Resources/Product.php +10 -8
- package/server/src/Models/AddonCategory.php +37 -0
- package/server/src/Models/Product.php +6 -7
- package/server/src/Models/ProductAddon.php +3 -0
- package/server/src/Models/ProductAddonCategory.php +12 -2
- package/server/src/Observers/CompanyObserver.php +20 -0
- package/server/src/Providers/StorefrontServiceProvider.php +2 -1
- package/server/src/Support/Storefront.php +249 -0
- package/translations/en-us.yaml +101 -39
- package/server/src/Support/OrderConfig.php +0 -14
|
@@ -28,40 +28,20 @@ class ReviewController extends Controller
|
|
|
28
28
|
$offset = $request->input('offset', false);
|
|
29
29
|
$sort = $request->input('sort');
|
|
30
30
|
|
|
31
|
+
if ($sort) {
|
|
32
|
+
$this->applySort($request, $sort);
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
if (session('storefront_store')) {
|
|
32
|
-
$results = Review::queryWithRequest($request, function (&$query) use ($
|
|
33
|
-
$query->where('subject_uuid',
|
|
36
|
+
$results = Review::queryWithRequest($request, function (&$query) use ($store, $limit, $offset) {
|
|
37
|
+
$query->where('subject_uuid', $store->uuid);
|
|
34
38
|
|
|
35
39
|
if ($limit) {
|
|
36
40
|
$query->limit($limit);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
if ($offset) {
|
|
40
|
-
$query->
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if ($sort) {
|
|
44
|
-
switch ($sort) {
|
|
45
|
-
case 'highest':
|
|
46
|
-
case 'highest rated':
|
|
47
|
-
$query->orderByDesc('rating');
|
|
48
|
-
break;
|
|
49
|
-
|
|
50
|
-
case 'lowest':
|
|
51
|
-
case 'lowest rated':
|
|
52
|
-
$query->orderBy('rating');
|
|
53
|
-
break;
|
|
54
|
-
|
|
55
|
-
case 'newest':
|
|
56
|
-
case 'newest first':
|
|
57
|
-
$query->orderByDesc('created_at');
|
|
58
|
-
break;
|
|
59
|
-
|
|
60
|
-
case 'oldest':
|
|
61
|
-
case 'oldest first':
|
|
62
|
-
$query->orderBy('created_at');
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
44
|
+
$query->offset($offset);
|
|
65
45
|
}
|
|
66
46
|
});
|
|
67
47
|
}
|
|
@@ -79,7 +59,7 @@ class ReviewController extends Controller
|
|
|
79
59
|
return response()->json(['error' => 'Cannot find reviews for store'], 400);
|
|
80
60
|
}
|
|
81
61
|
|
|
82
|
-
$results = Review::queryWithRequest($request, function (&$query) use ($store, $
|
|
62
|
+
$results = Review::queryWithRequest($request, function (&$query) use ($store, $limit, $offset) {
|
|
83
63
|
$query->where('subject_uuid', $store->uuid);
|
|
84
64
|
|
|
85
65
|
if ($limit) {
|
|
@@ -89,30 +69,6 @@ class ReviewController extends Controller
|
|
|
89
69
|
if ($offset) {
|
|
90
70
|
$query->limit($offset);
|
|
91
71
|
}
|
|
92
|
-
|
|
93
|
-
if ($sort) {
|
|
94
|
-
switch ($sort) {
|
|
95
|
-
case 'highest':
|
|
96
|
-
case 'highest rated':
|
|
97
|
-
$query->orderByDesc('rating');
|
|
98
|
-
break;
|
|
99
|
-
|
|
100
|
-
case 'lowest':
|
|
101
|
-
case 'lowest rated':
|
|
102
|
-
$query->orderBy('rating');
|
|
103
|
-
break;
|
|
104
|
-
|
|
105
|
-
case 'newest':
|
|
106
|
-
case 'newest first':
|
|
107
|
-
$query->orderByDesc('created_at');
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
case 'oldest':
|
|
111
|
-
case 'oldest first':
|
|
112
|
-
$query->orderBy('created_at');
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
72
|
});
|
|
117
73
|
}
|
|
118
74
|
}
|
|
@@ -120,6 +76,41 @@ class ReviewController extends Controller
|
|
|
120
76
|
return StorefrontReview::collection($results);
|
|
121
77
|
}
|
|
122
78
|
|
|
79
|
+
public function applySort($request, $sort)
|
|
80
|
+
{
|
|
81
|
+
if ($sort) {
|
|
82
|
+
switch ($sort) {
|
|
83
|
+
case 'highest':
|
|
84
|
+
case 'highest rated':
|
|
85
|
+
$request->merge(['sort' => 'rating', 'sort_direction' => 'desc']);
|
|
86
|
+
|
|
87
|
+
break;
|
|
88
|
+
|
|
89
|
+
case 'lowest':
|
|
90
|
+
case 'lowest rated':
|
|
91
|
+
$request->merge(['sort' => 'rating', 'sort_direction' => 'asc']);
|
|
92
|
+
|
|
93
|
+
break;
|
|
94
|
+
|
|
95
|
+
case 'newest':
|
|
96
|
+
case 'newest first':
|
|
97
|
+
$request->merge(['sort' => 'created_at', 'sort_direction' => 'desc']);
|
|
98
|
+
|
|
99
|
+
break;
|
|
100
|
+
|
|
101
|
+
case 'oldest':
|
|
102
|
+
case 'oldest first':
|
|
103
|
+
$request->merge(['sort' => 'created_at', 'sort_direction' => 'asc']);
|
|
104
|
+
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
default:
|
|
108
|
+
// Handle unknown sorting criteria
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
123
114
|
/**
|
|
124
115
|
* Coutns the number of ratings between 1-5 for a store.
|
|
125
116
|
*
|
|
@@ -5,11 +5,11 @@ namespace Fleetbase\Storefront\Http\Controllers\v1;
|
|
|
5
5
|
use Fleetbase\FleetOps\Http\Resources\v1\ServiceQuote as ServiceQuoteResource;
|
|
6
6
|
use Fleetbase\FleetOps\Models\Entity;
|
|
7
7
|
use Fleetbase\FleetOps\Models\IntegratedVendor;
|
|
8
|
+
use Fleetbase\FleetOps\Models\OrderConfig;
|
|
8
9
|
use Fleetbase\FleetOps\Models\Place;
|
|
9
10
|
use Fleetbase\FleetOps\Models\ServiceQuote;
|
|
10
11
|
use Fleetbase\FleetOps\Models\ServiceQuoteItem;
|
|
11
12
|
use Fleetbase\FleetOps\Models\ServiceRate;
|
|
12
|
-
use Fleetbase\FleetOps\Support\Flow;
|
|
13
13
|
use Fleetbase\FleetOps\Support\Utils;
|
|
14
14
|
use Fleetbase\Http\Controllers\Controller;
|
|
15
15
|
use Fleetbase\Storefront\Http\Requests\GetServiceQuoteFromCart;
|
|
@@ -100,12 +100,11 @@ class ServiceQuoteController extends Controller
|
|
|
100
100
|
$serviceQuotes = collect();
|
|
101
101
|
|
|
102
102
|
// get order configurations for ecommerce / task
|
|
103
|
-
$
|
|
104
|
-
|
|
105
|
-
});
|
|
103
|
+
$orderConfig = OrderConfig::resolveFromIdentifier($config);
|
|
104
|
+
$orderConfigKey = data_get($orderConfig, 'key', 'storefront');
|
|
106
105
|
|
|
107
106
|
// get service rates for config type
|
|
108
|
-
$serviceRates = ServiceRate::
|
|
107
|
+
$serviceRates = ServiceRate::where('service_type', $orderConfigKey)->get();
|
|
109
108
|
|
|
110
109
|
// if no service rates send an empty quote
|
|
111
110
|
if ($serviceRates->isEmpty()) {
|
|
@@ -289,12 +288,11 @@ class ServiceQuoteController extends Controller
|
|
|
289
288
|
$serviceQuotes = collect();
|
|
290
289
|
|
|
291
290
|
// get order configurations for ecommerce / task
|
|
292
|
-
$
|
|
293
|
-
|
|
294
|
-
});
|
|
291
|
+
$orderConfig = OrderConfig::resolveFromIdentifier($config);
|
|
292
|
+
$orderConfigKey = data_get($orderConfig, 'key', 'storefront');
|
|
295
293
|
|
|
296
294
|
// get service rates for config type
|
|
297
|
-
$serviceRates = ServiceRate::
|
|
295
|
+
$serviceRates = ServiceRate::where('service_type', $orderConfigKey)->get();
|
|
298
296
|
|
|
299
297
|
// if no service rates send an empty quote
|
|
300
298
|
if ($serviceRates->isEmpty()) {
|
|
@@ -17,38 +17,40 @@ class Network extends FleetbaseResource
|
|
|
17
17
|
public function toArray($request)
|
|
18
18
|
{
|
|
19
19
|
return [
|
|
20
|
-
'id'
|
|
21
|
-
'uuid'
|
|
22
|
-
'public_id'
|
|
23
|
-
'key'
|
|
24
|
-
'company_uuid'
|
|
25
|
-
'created_by_uuid'
|
|
26
|
-
'logo_uuid'
|
|
27
|
-
'backdrop_uuid'
|
|
28
|
-
'name'
|
|
29
|
-
'description'
|
|
30
|
-
'translations'
|
|
31
|
-
'website'
|
|
32
|
-
'facebook'
|
|
33
|
-
'instagram'
|
|
34
|
-
'twitter'
|
|
35
|
-
'email'
|
|
36
|
-
'phone'
|
|
37
|
-
'tags'
|
|
38
|
-
'currency'
|
|
39
|
-
'options'
|
|
40
|
-
'alertable'
|
|
41
|
-
'logo_url'
|
|
42
|
-
'backdrop_url'
|
|
43
|
-
'rating'
|
|
44
|
-
'online'
|
|
45
|
-
'stores'
|
|
46
|
-
'categories'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
20
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
21
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
22
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
23
|
+
'key' => $this->when(Http::isInternalRequest(), $this->key),
|
|
24
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
25
|
+
'created_by_uuid' => $this->when(Http::isInternalRequest(), $this->created_by_uuid),
|
|
26
|
+
'logo_uuid' => $this->when(Http::isInternalRequest(), $this->logo_uuid),
|
|
27
|
+
'backdrop_uuid' => $this->when(Http::isInternalRequest(), $this->backdrop_uuid),
|
|
28
|
+
'name' => $this->name,
|
|
29
|
+
'description' => $this->description,
|
|
30
|
+
'translations' => $this->translations ?? [],
|
|
31
|
+
'website' => $this->website,
|
|
32
|
+
'facebook' => $this->facebook,
|
|
33
|
+
'instagram' => $this->instagram,
|
|
34
|
+
'twitter' => $this->twitter,
|
|
35
|
+
'email' => $this->email,
|
|
36
|
+
'phone' => $this->phone,
|
|
37
|
+
'tags' => $this->tags ?? [],
|
|
38
|
+
'currency' => $this->currency ?? 'USD',
|
|
39
|
+
'options' => $this->options ?? [],
|
|
40
|
+
'alertable' => $this->alertable,
|
|
41
|
+
'logo_url' => $this->logo_url,
|
|
42
|
+
'backdrop_url' => $this->backdrop_url,
|
|
43
|
+
'rating' => $this->rating,
|
|
44
|
+
'online' => $this->online,
|
|
45
|
+
'stores' => $this->when($request->boolean('with_stores') || $request->inArray('with', 'stores'), Store::collection($this->stores)),
|
|
46
|
+
'categories' => $this->when($request->boolean('with_categories') || $request->inArray('with', 'categories'), Category::collection($this->categories)),
|
|
47
|
+
'gateways' => $this->when($request->boolean('with_gateways') || $request->inArray('with', 'gateways'), Gateway::collection($this->gateways)),
|
|
48
|
+
'notification_channels' => $this->when($request->boolean('with_notification_channels') || $request->inArray('with', 'notification_channels'), NotificationChannel::collection($this->notificationChannels)),
|
|
49
|
+
'is_network' => true,
|
|
50
|
+
'is_store' => false,
|
|
51
|
+
'slug' => $this->slug,
|
|
52
|
+
'created_at' => $this->created_at,
|
|
53
|
+
'updated_at' => $this->updated_at,
|
|
52
54
|
];
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class NotificationChannel extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
*
|
|
15
|
+
* @return array
|
|
16
|
+
*/
|
|
17
|
+
public function toArray($request)
|
|
18
|
+
{
|
|
19
|
+
return [
|
|
20
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
21
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
22
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
23
|
+
'name' => $this->name,
|
|
24
|
+
'scheme' => $this->scheme,
|
|
25
|
+
'options' => $this->options,
|
|
26
|
+
'is_apn_gateway' => $this->is_apn_gateway,
|
|
27
|
+
'is_fcm_gateway' => $this->is_fcm_gateway,
|
|
28
|
+
'created_at' => $this->created_at,
|
|
29
|
+
'updated_at' => $this->updated_at,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -97,14 +97,16 @@ class Product extends FleetbaseResource
|
|
|
97
97
|
|
|
98
98
|
if (Http::isInternalRequest()) {
|
|
99
99
|
return [
|
|
100
|
-
'uuid'
|
|
101
|
-
'
|
|
102
|
-
'
|
|
103
|
-
'
|
|
104
|
-
'
|
|
105
|
-
'
|
|
106
|
-
'
|
|
107
|
-
'
|
|
100
|
+
'uuid' => $addonCategory->uuid,
|
|
101
|
+
'product_uuid' => $addonCategory->product_uuid,
|
|
102
|
+
'category_uuid' => $addonCategory->category_uuid,
|
|
103
|
+
'public_id' => data_get($addonCategory, 'category.public_id'),
|
|
104
|
+
'id' => $addonCategory->id,
|
|
105
|
+
'name' => $addonCategory->name,
|
|
106
|
+
'excluded_addons' => $addonCategory->excluded_addons,
|
|
107
|
+
'category' => $addonCategory->category,
|
|
108
|
+
'created_at' => $addonCategory->created_at,
|
|
109
|
+
'updated_at' => $addonCategory->updated_at,
|
|
108
110
|
];
|
|
109
111
|
} else {
|
|
110
112
|
return [
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Models;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Models\Category;
|
|
6
|
+
use Illuminate\Support\Arr;
|
|
7
|
+
use Illuminate\Support\Str;
|
|
6
8
|
|
|
7
9
|
class AddonCategory extends Category
|
|
8
10
|
{
|
|
@@ -25,4 +27,39 @@ class AddonCategory extends Category
|
|
|
25
27
|
{
|
|
26
28
|
return $this->setConnection(config('storefront.connection.db'))->hasMany(ProductAddon::class, 'category_uuid');
|
|
27
29
|
}
|
|
30
|
+
|
|
31
|
+
public function setAddons(array $addons = []): AddonCategory
|
|
32
|
+
{
|
|
33
|
+
foreach ($addons as $addon) {
|
|
34
|
+
// get uuid if set
|
|
35
|
+
$id = data_get($addon, 'uuid');
|
|
36
|
+
|
|
37
|
+
// make sure the cateogry is set to this current
|
|
38
|
+
data_set($addon, 'category_uuid', $this->uuid);
|
|
39
|
+
|
|
40
|
+
// make sure sale price is 0 if null
|
|
41
|
+
if (data_get($addon, 'sale_price') === null) {
|
|
42
|
+
data_set($addon, 'sale_price', 0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// update product addon category
|
|
46
|
+
if (Str::isUuid($id)) {
|
|
47
|
+
ProductAddon::where('uuid', $id)->update(Arr::except($addon, ['uuid', 'created_at', 'updated_at']));
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// create new product addon category
|
|
52
|
+
ProductAddon::create([
|
|
53
|
+
'category_uuid' => $this->uuid,
|
|
54
|
+
'name' => data_get($addon, 'name'),
|
|
55
|
+
'description' => data_get($addon, 'description'),
|
|
56
|
+
'translations' => data_get($addon, 'translations', []),
|
|
57
|
+
'price' => data_get($addon, 'price'),
|
|
58
|
+
'sale_price' => data_get($addon, 'sale_price'),
|
|
59
|
+
'is_on_sale' => data_get($addon, 'is_on_sale'),
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return $this;
|
|
64
|
+
}
|
|
28
65
|
}
|
|
@@ -304,18 +304,17 @@ class Product extends StorefrontModel
|
|
|
304
304
|
// get uuid if set
|
|
305
305
|
$id = data_get($addonCategory, 'uuid');
|
|
306
306
|
|
|
307
|
+
// Make sure product is set
|
|
308
|
+
data_set($addonCategory, 'product_uuid', $this->uuid);
|
|
309
|
+
|
|
307
310
|
// update product addon category
|
|
308
311
|
if (Str::isUuid($id)) {
|
|
309
|
-
ProductAddonCategory::where('uuid', $id)->update([
|
|
310
|
-
'excluded_addons' => data_get($addonCategory, 'excluded_addons'),
|
|
311
|
-
'max_selectable' => data_get($addonCategory, 'max_selectable'),
|
|
312
|
-
'is_required' => data_get($addonCategory, 'is_required'),
|
|
313
|
-
]);
|
|
312
|
+
ProductAddonCategory::where('uuid', $id)->update(Arr::except($addonCategory, ['uuid', 'created_at', 'updated_at', 'name', 'category']));
|
|
314
313
|
continue;
|
|
315
314
|
}
|
|
316
315
|
|
|
317
316
|
// create new product addon category
|
|
318
|
-
|
|
317
|
+
ProductAddonCategory::create([
|
|
319
318
|
'product_uuid' => $this->uuid,
|
|
320
319
|
'category_uuid' => data_get($addonCategory, 'category_uuid'),
|
|
321
320
|
'excluded_addons' => data_get($addonCategory, 'excluded_addons'),
|
|
@@ -369,7 +368,7 @@ class Product extends StorefrontModel
|
|
|
369
368
|
$option['additional_cost'] = Utils::numbersOnly($option['additional_cost']);
|
|
370
369
|
}
|
|
371
370
|
|
|
372
|
-
$productVariantOptionInput = Arr::except($option, ['uuid']);
|
|
371
|
+
$productVariantOptionInput = Arr::except($option, ['uuid', 'created_at', 'updated_at']);
|
|
373
372
|
ProductVariantOption::where('uuid', $option['uuid'])->update($productVariantOptionInput);
|
|
374
373
|
continue;
|
|
375
374
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Models;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Casts\Json;
|
|
6
|
+
use Fleetbase\Casts\Money;
|
|
6
7
|
use Fleetbase\FleetOps\Support\Utils;
|
|
7
8
|
use Fleetbase\Models\Category;
|
|
8
9
|
use Fleetbase\Models\User;
|
|
@@ -66,6 +67,8 @@ class ProductAddon extends StorefrontModel
|
|
|
66
67
|
protected $casts = [
|
|
67
68
|
'is_on_sale' => 'boolean',
|
|
68
69
|
'translations' => Json::class,
|
|
70
|
+
'price' => Money::class,
|
|
71
|
+
'sale_price' => Money::class,
|
|
69
72
|
];
|
|
70
73
|
|
|
71
74
|
/**
|
|
@@ -84,8 +84,18 @@ class ProductAddonCategory extends StorefrontModel
|
|
|
84
84
|
return static::attributeFromCache($this, 'category.name');
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Decode excluded addons.
|
|
89
|
+
*
|
|
90
|
+
* @param string $excluded
|
|
91
|
+
*/
|
|
92
|
+
public function getExcludedAddonsAttribute($excluded): array
|
|
88
93
|
{
|
|
89
|
-
|
|
94
|
+
$excludedAddons = is_array($excluded) ? $excluded : Json::decode($excluded);
|
|
95
|
+
if (is_array($excludedAddons)) {
|
|
96
|
+
return $excludedAddons;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return [];
|
|
90
100
|
}
|
|
91
101
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Observers;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Models\Company;
|
|
6
|
+
use Fleetbase\Storefront\Support\Storefront;
|
|
7
|
+
|
|
8
|
+
class CompanyObserver
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Handle the Company "created" event.
|
|
12
|
+
*
|
|
13
|
+
* @return void
|
|
14
|
+
*/
|
|
15
|
+
public function created(Company $company)
|
|
16
|
+
{
|
|
17
|
+
// Add the default storefront order config
|
|
18
|
+
Storefront::createStorefrontConfig($company);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -26,6 +26,7 @@ class StorefrontServiceProvider extends CoreServiceProvider
|
|
|
26
26
|
public $observers = [
|
|
27
27
|
\Fleetbase\Storefront\Models\Product::class => \Fleetbase\Storefront\Observers\ProductObserver::class,
|
|
28
28
|
\Fleetbase\Storefront\Models\Network::class => \Fleetbase\Storefront\Observers\NetworkObserver::class,
|
|
29
|
+
\Fleetbase\Models\Company::class => \Fleetbase\Storefront\Observers\CompanyObserver::class,
|
|
29
30
|
];
|
|
30
31
|
|
|
31
32
|
/**
|
|
@@ -86,7 +87,7 @@ class StorefrontServiceProvider extends CoreServiceProvider
|
|
|
86
87
|
{
|
|
87
88
|
$this->registerCommands();
|
|
88
89
|
$this->scheduleCommands(function ($schedule) {
|
|
89
|
-
$schedule->command('storefront:notify-order-nearby')->everyMinute();
|
|
90
|
+
$schedule->command('storefront:notify-order-nearby')->everyMinute()->storeOutputInDb();
|
|
90
91
|
});
|
|
91
92
|
$this->registerObservers();
|
|
92
93
|
$this->registerMiddleware();
|