@fleetbase/storefront-engine 0.2.11 → 0.3.1
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/controllers/networks/index/network/index.js +1 -1
- package/addon/controllers/products/index/category/new.js +2 -2
- package/addon/templates/networks/index/network/index.hbs +4 -1
- package/addon/templates/settings/gateways.hbs +1 -1
- package/composer.json +3 -3
- package/extension.json +1 -1
- package/package.json +3 -3
- package/server/src/Http/Controllers/MetricsController.php +1 -2
- package/server/src/Http/Controllers/v1/CustomerController.php +18 -10
- package/server/src/Http/Controllers/v1/NetworkController.php +1 -1
- package/server/src/Http/Controllers/v1/ProductController.php +1 -1
- package/server/src/Http/Controllers/v1/ServiceQuoteController.php +3 -2
- package/server/src/Http/Controllers/v1/StoreController.php +1 -1
- package/server/src/Http/Requests/GetServiceQuoteFromCart.php +1 -1
- package/server/src/Http/Requests/InitializeCheckoutRequest.php +2 -3
- package/server/src/Http/Resources/Category.php +1 -1
- package/server/src/Http/Resources/ReviewCustomer.php +0 -28
- package/server/src/Imports/ProductsImport.php +1 -1
- package/server/src/Listeners/HandleOrderDriverAssigned.php +1 -1
- package/server/src/Models/Gateway.php +1 -1
- package/server/src/Models/Network.php +2 -2
- package/server/src/Models/Product.php +1 -1
- package/server/src/Models/ProductAddon.php +1 -1
- package/server/src/Models/ProductStoreLocation.php +1 -1
- package/server/src/Models/ProductVariant.php +1 -1
- package/server/src/Models/Store.php +2 -2
- package/server/src/Models/StoreLocation.php +0 -2
- package/server/src/Notifications/StorefrontOrderCanceled.php +2 -2
- package/server/src/Notifications/StorefrontOrderCompleted.php +1 -1
- package/server/src/Notifications/StorefrontOrderCreated.php +1 -1
- package/server/src/Notifications/StorefrontOrderDriverAssigned.php +1 -1
- package/server/src/Notifications/StorefrontOrderEnroute.php +1 -1
- package/server/src/Notifications/StorefrontOrderNearby.php +1 -1
- package/server/src/Notifications/StorefrontOrderPreparing.php +1 -1
- package/server/src/Notifications/StorefrontOrderReadyForPickup.php +1 -1
- package/server/src/Observers/NetworkObserver.php +1 -1
- package/server/src/Observers/ProductObserver.php +2 -2
- package/server/src/Providers/StorefrontServiceProvider.php +0 -1
- package/server/src/Rules/CartExists.php +31 -0
- package/server/src/Rules/CustomerExists.php +34 -0
- package/server/src/Rules/GatewayExists.php +35 -0
- package/server/src/Rules/IsValidLocation.php +54 -0
- package/server/src/Support/Storefront.php +2 -1
- package/server/config/twilio-notification-channel.php +0 -36
|
@@ -89,7 +89,7 @@ export default class NetworksIndexNetworkIndexController extends Controller {
|
|
|
89
89
|
this.model
|
|
90
90
|
.save()
|
|
91
91
|
.then(() => {
|
|
92
|
-
this.notifications.success(this.intl.t('storefront.
|
|
92
|
+
this.notifications.success(this.intl.t('storefront.networks.index.network.index.change-network-saved'));
|
|
93
93
|
})
|
|
94
94
|
.catch((error) => {
|
|
95
95
|
this.notifications.serverError(error);
|
|
@@ -140,10 +140,10 @@ export default class ProductsIndexCategoryNewController extends BaseController {
|
|
|
140
140
|
|
|
141
141
|
@action makePrimaryFile(file) {
|
|
142
142
|
if (file.isNotImage) {
|
|
143
|
-
return this.notifications.warning(this.intl.t('storefront.products.index.
|
|
143
|
+
return this.notifications.warning(this.intl.t('storefront.products.index.new.warning-only-select-an-image-file-to-be-primary'));
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
this.notifications.success(this.intl.t('storefront.products.index.
|
|
146
|
+
this.notifications.success(this.intl.t('storefront.products.index.new.made-the-primary-success-image', { fileName: file.original_filename }));
|
|
147
147
|
this.product.primary_image_uuid = file.id;
|
|
148
148
|
this.product.primary_image_url = file.url;
|
|
149
149
|
this.product.primary_image = file;
|
|
@@ -183,7 +183,10 @@
|
|
|
183
183
|
}}</span>
|
|
184
184
|
</Toggle>
|
|
185
185
|
{{#if @model.options.require_pod}}
|
|
186
|
-
<InputGroup
|
|
186
|
+
<InputGroup
|
|
187
|
+
@wrapperClass="mb-0 mt-2"
|
|
188
|
+
@name={{t "storefront.networks.index.network.index.general-network-settings-form.config-switches.proof-of-delivery-method-label"}}
|
|
189
|
+
>
|
|
187
190
|
<Select
|
|
188
191
|
@options={{this.podMethods}}
|
|
189
192
|
@optionValue="value"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
{{#each this.
|
|
18
|
+
{{#each this.model as |gateway|}}
|
|
19
19
|
<ContentPanel @title={{gateway.name}} @open={{true}} @pad={{true}}>
|
|
20
20
|
<InputGroup @name={{t "storefront.settings.gateways.gateway-name"}} @value={{gateway.name}} @helpText={{t "storefront.settings.gateways.helpText"}} />
|
|
21
21
|
<InputGroup @name={{t "storefront.settings.gateways.gateway-code"}} @value={{gateway.code}} @disabled={{true}} @helpText={{t "storefront.settings.gateways.gateway-code-help-text"}} />
|
package/composer.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetbase/storefront-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fleetbase-extension",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"require": {
|
|
24
24
|
"php": "^8.0",
|
|
25
|
-
"fleetbase/core-api": "^1.4.
|
|
26
|
-
"fleetbase/fleetops-api": "^0.4.
|
|
25
|
+
"fleetbase/core-api": "^1.4.7",
|
|
26
|
+
"fleetbase/fleetops-api": "^0.4.13",
|
|
27
27
|
"geocoder-php/google-maps-places-provider": "^1.4",
|
|
28
28
|
"laravel-notification-channels/apn": "^5.0",
|
|
29
29
|
"laravel-notification-channels/fcm": "^4.1",
|
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetbase/storefront-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
|
|
5
5
|
"fleetbase": {
|
|
6
6
|
"route": "storefront",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@fleetbase/ember-core": "^0.2.4",
|
|
47
|
-
"@fleetbase/ember-ui": "^0.2.
|
|
48
|
-
"@fleetbase/fleetops-data": "^0.1.
|
|
47
|
+
"@fleetbase/ember-ui": "^0.2.11",
|
|
48
|
+
"@fleetbase/fleetops-data": "^0.1.9",
|
|
49
49
|
"@babel/core": "^7.23.2",
|
|
50
50
|
"@fortawesome/ember-fontawesome": "^0.4.1",
|
|
51
51
|
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
|
@@ -9,9 +9,8 @@ use Illuminate\Http\Request;
|
|
|
9
9
|
class MetricsController extends Controller
|
|
10
10
|
{
|
|
11
11
|
/**
|
|
12
|
-
* Get all key metrics for a companies storefront
|
|
12
|
+
* Get all key metrics for a companies storefront.
|
|
13
13
|
*
|
|
14
|
-
* @param \Illuminate\Http\Request $request
|
|
15
14
|
* @return \Illuminate\Http\Response
|
|
16
15
|
*/
|
|
17
16
|
public function all(Request $request)
|
|
@@ -9,7 +9,6 @@ use Fleetbase\FleetOps\Http\Resources\v1\Place as PlaceResource;
|
|
|
9
9
|
use Fleetbase\FleetOps\Models\Contact;
|
|
10
10
|
use Fleetbase\FleetOps\Models\Order;
|
|
11
11
|
use Fleetbase\FleetOps\Models\Place;
|
|
12
|
-
use Fleetbase\FleetOps\Support\Utils;
|
|
13
12
|
use Fleetbase\Http\Controllers\Controller;
|
|
14
13
|
use Fleetbase\Models\User;
|
|
15
14
|
use Fleetbase\Models\UserDevice;
|
|
@@ -18,6 +17,7 @@ use Fleetbase\Storefront\Http\Requests\CreateCustomerRequest;
|
|
|
18
17
|
use Fleetbase\Storefront\Http\Requests\VerifyCreateCustomerRequest;
|
|
19
18
|
use Fleetbase\Storefront\Http\Resources\Customer;
|
|
20
19
|
use Fleetbase\Storefront\Support\Storefront;
|
|
20
|
+
use Fleetbase\Support\Utils;
|
|
21
21
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
22
22
|
use Illuminate\Http\Request;
|
|
23
23
|
use Illuminate\Support\Facades\Hash;
|
|
@@ -136,13 +136,19 @@ class CustomerController extends Controller
|
|
|
136
136
|
$meta = ['identity' => $identity];
|
|
137
137
|
|
|
138
138
|
if ($isEmail) {
|
|
139
|
-
VerificationCode::generateEmailVerificationFor($customer, 'storefront_create_customer',
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
VerificationCode::generateEmailVerificationFor($customer, 'storefront_create_customer', [
|
|
140
|
+
'messageCallback' => function ($verification) use ($about) {
|
|
141
|
+
return "Your {$about->name} verification code is {$verification->code}";
|
|
142
|
+
},
|
|
143
|
+
'meta' => $meta,
|
|
144
|
+
]);
|
|
142
145
|
} else {
|
|
143
|
-
VerificationCode::generateSmsVerificationFor($customer, 'storefront_create_customer',
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
VerificationCode::generateSmsVerificationFor($customer, 'storefront_create_customer', [
|
|
147
|
+
'messageCallback' => function ($verification) use ($about) {
|
|
148
|
+
return "Your {$about->name} verification code is {$verification->code}";
|
|
149
|
+
},
|
|
150
|
+
'meta' => $meta,
|
|
151
|
+
]);
|
|
146
152
|
}
|
|
147
153
|
|
|
148
154
|
return response()->json(['status' => 'ok']);
|
|
@@ -382,9 +388,11 @@ class CustomerController extends Controller
|
|
|
382
388
|
$about = Storefront::about();
|
|
383
389
|
|
|
384
390
|
// generate verification token
|
|
385
|
-
VerificationCode::generateSmsVerificationFor($user, 'storefront_login',
|
|
386
|
-
|
|
387
|
-
|
|
391
|
+
VerificationCode::generateSmsVerificationFor($user, 'storefront_login', [
|
|
392
|
+
'messageCallback' => function ($verification) use ($about) {
|
|
393
|
+
return "Your {$about->name} verification code is {$verification->code}";
|
|
394
|
+
},
|
|
395
|
+
]);
|
|
388
396
|
|
|
389
397
|
return response()->json(['status' => 'OK']);
|
|
390
398
|
}
|
|
@@ -4,12 +4,12 @@ namespace Fleetbase\Storefront\Http\Controllers\v1;
|
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Support\Utils;
|
|
6
6
|
use Fleetbase\Http\Controllers\Controller;
|
|
7
|
+
use Fleetbase\LaravelMysqlSpatial\Types\Point;
|
|
7
8
|
use Fleetbase\Models\Category;
|
|
8
9
|
use Fleetbase\Storefront\Http\Resources\Store as StorefrontStore;
|
|
9
10
|
use Fleetbase\Storefront\Http\Resources\StoreLocation as StorefrontStoreLocation;
|
|
10
11
|
use Fleetbase\Storefront\Models\Store;
|
|
11
12
|
use Fleetbase\Storefront\Models\StoreLocation;
|
|
12
|
-
use Fleetbase\LaravelMysqlSpatial\Types\Point;
|
|
13
13
|
use Illuminate\Http\Request;
|
|
14
14
|
|
|
15
15
|
class NetworkController extends Controller
|
|
@@ -17,6 +17,7 @@ use Fleetbase\Storefront\Models\Cart;
|
|
|
17
17
|
use Fleetbase\Storefront\Models\Product;
|
|
18
18
|
use Fleetbase\Storefront\Models\Store;
|
|
19
19
|
use Fleetbase\Storefront\Models\StoreLocation;
|
|
20
|
+
use Fleetbase\Support\Utils as CoreUtils;
|
|
20
21
|
use Illuminate\Support\Str;
|
|
21
22
|
|
|
22
23
|
class ServiceQuoteController extends Controller
|
|
@@ -30,7 +31,7 @@ class ServiceQuoteController extends Controller
|
|
|
30
31
|
*/
|
|
31
32
|
public function fromCart(GetServiceQuoteFromCart $request)
|
|
32
33
|
{
|
|
33
|
-
$requestId =
|
|
34
|
+
$requestId = CoreUtils::generatePublicId('request');
|
|
34
35
|
$origin = $this->getPlaceFromId($request->input('origin'));
|
|
35
36
|
$destination = $this->getPlaceFromId($request->input('destination'));
|
|
36
37
|
$facilitator = $request->input('facilitator');
|
|
@@ -302,7 +303,7 @@ class ServiceQuoteController extends Controller
|
|
|
302
303
|
|
|
303
304
|
if ($integratedVendor) {
|
|
304
305
|
try {
|
|
305
|
-
/** @var
|
|
306
|
+
/** @var ServiceQuote $serviceQuote */
|
|
306
307
|
$serviceQuote = $integratedVendor->api()->setRequestId($requestId)->getQuoteFromPreliminaryPayload([...$origins, $destination], [], $serviceType, $scheduledAt, $isRouteOptimized);
|
|
307
308
|
} catch (\Exception $e) {
|
|
308
309
|
return response()->error($e->getMessage());
|
|
@@ -109,7 +109,7 @@ class StoreController extends Controller
|
|
|
109
109
|
|
|
110
110
|
// if cod is enabled add cash as a gateway
|
|
111
111
|
if ($about->hasOption('cod_enabled')) {
|
|
112
|
-
$gateways->push(Gateway::cash(
|
|
112
|
+
$gateways->push(Gateway::cash(['sandbox'=>$sandbox]));
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
return GatewayResource::collection($gateways);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Http\Requests;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
-
use Fleetbase\Rules\IsValidLocation;
|
|
6
|
+
use Fleetbase\Storefront\Rules\IsValidLocation;
|
|
7
7
|
use Illuminate\Support\Str;
|
|
8
8
|
|
|
9
9
|
class GetServiceQuoteFromCart extends FleetbaseRequest
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Http\Requests;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Http\Requests\FleetbaseRequest;
|
|
6
|
-
|
|
7
|
-
use Fleetbase\Rules\
|
|
8
|
-
use Fleetbase\Rules\Storefront\GatewayExists;
|
|
6
|
+
use Fleetbase\Storefront\Rules\CustomerExists;
|
|
7
|
+
use Fleetbase\Storefront\Rules\GatewayExists;
|
|
9
8
|
|
|
10
9
|
class InitializeCheckoutRequest extends FleetbaseRequest
|
|
11
10
|
{
|
|
@@ -30,7 +30,7 @@ class Category extends FleetbaseResource
|
|
|
30
30
|
),
|
|
31
31
|
'tags' => $this->tags ?? [],
|
|
32
32
|
'translations' => $this->translations ?? [],
|
|
33
|
-
'products' => $this->when($request->has('with_products') || $request->inArray('with', 'products'), Product::collection($this->products)),
|
|
33
|
+
'products' => $this->when($request->has('with_products') || $request->inArray('with', 'products'), $this->products ? Product::collection($this->products) : []),
|
|
34
34
|
'subcategories' => $this->when(
|
|
35
35
|
$request->has('with_subcategories') || $request->inArray('with', 'subcategories'),
|
|
36
36
|
array_map(
|
|
@@ -25,37 +25,9 @@ class ReviewCustomer extends FleetbaseResource
|
|
|
25
25
|
'email' => $this->email,
|
|
26
26
|
'phone' => $this->phone,
|
|
27
27
|
'photo_url' => $this->photo_url,
|
|
28
|
-
'reviews_count' => $this->getReviewsCount(),
|
|
29
|
-
'uploads_count' => $this->getUploadsCount(),
|
|
30
28
|
'slug' => $this->slug,
|
|
31
29
|
'created_at' => $this->created_at,
|
|
32
30
|
'updated_at' => $this->updated_at,
|
|
33
31
|
];
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
public function getReviewsCount()
|
|
37
|
-
{
|
|
38
|
-
if (session('storefront_network')) {
|
|
39
|
-
return $this->storeReviews()->whereHas('subject', function ($q) {
|
|
40
|
-
$q->whereHas('networks', function ($q) {
|
|
41
|
-
$q->where('network_uuid', session('storefront_network'));
|
|
42
|
-
});
|
|
43
|
-
})->count();
|
|
44
|
-
|
|
45
|
-
// $productReviewsCount = $this->productReviews()->whereHas('subject', function ($q) {
|
|
46
|
-
// $q->whereHas('store', function ($q) {
|
|
47
|
-
// $q->whereHas('networks', function ($q) {
|
|
48
|
-
// $q->where('network_uuid', session('storefront_network'));
|
|
49
|
-
// });
|
|
50
|
-
// });
|
|
51
|
-
// })->count();
|
|
52
|
-
|
|
53
|
-
// return $storeReviewsCount + $productReviewsCount;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public function getUploadsCount()
|
|
58
|
-
{
|
|
59
|
-
return $this->reviewUploads()->count();
|
|
60
|
-
}
|
|
61
33
|
}
|
|
@@ -21,7 +21,7 @@ class HandleOrderDriverAssigned implements ShouldQueue
|
|
|
21
21
|
*/
|
|
22
22
|
public function handle(OrderDriverAssigned $event)
|
|
23
23
|
{
|
|
24
|
-
/** @var
|
|
24
|
+
/** @var Order $order */
|
|
25
25
|
$order = $event->getModelRecord();
|
|
26
26
|
|
|
27
27
|
// halt if unable to resolve order record from event
|
|
@@ -149,7 +149,7 @@ class Gateway extends StorefrontModel
|
|
|
149
149
|
/**
|
|
150
150
|
* Generates a new cash/cash on delivery gateway.
|
|
151
151
|
*/
|
|
152
|
-
public static function cash($attributes = ['sandbox' =>
|
|
152
|
+
public static function cash($attributes = ['sandbox' => false]): Gateway
|
|
153
153
|
{
|
|
154
154
|
return new static([
|
|
155
155
|
'public_id' => 'gateway_cash',
|
|
@@ -21,7 +21,7 @@ use Spatie\Sluggable\SlugOptions;
|
|
|
21
21
|
class Network extends StorefrontModel
|
|
22
22
|
{
|
|
23
23
|
use HasUuid;
|
|
24
|
-
use
|
|
24
|
+
use HasPublicid;
|
|
25
25
|
use HasApiModelBehavior;
|
|
26
26
|
use HasOptionsAttributes;
|
|
27
27
|
use HasSlug;
|
|
@@ -83,7 +83,7 @@ class Network extends StorefrontModel
|
|
|
83
83
|
protected $hidden = ['logo', 'backdrop', 'files', 'media'];
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* @var
|
|
86
|
+
* @var SlugOptions
|
|
87
87
|
*/
|
|
88
88
|
public function getSlugOptions(): SlugOptions
|
|
89
89
|
{
|
|
@@ -95,7 +95,7 @@ class Store extends StorefrontModel
|
|
|
95
95
|
protected $filterParams = ['network', 'without_category', 'category', 'category_uuid'];
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* @var
|
|
98
|
+
* @var SlugOptions
|
|
99
99
|
*/
|
|
100
100
|
public function getSlugOptions(): SlugOptions
|
|
101
101
|
{
|
|
@@ -332,7 +332,7 @@ class Store extends StorefrontModel
|
|
|
332
332
|
/**
|
|
333
333
|
* Retrieves the category of the store belonging to the specified network.
|
|
334
334
|
*
|
|
335
|
-
* @param
|
|
335
|
+
* @param Network $network the network for which the category is to be retrieved
|
|
336
336
|
*
|
|
337
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
|
|
338
338
|
*/
|
|
@@ -7,14 +7,12 @@ use Fleetbase\Models\User;
|
|
|
7
7
|
use Fleetbase\Traits\HasApiModelBehavior;
|
|
8
8
|
use Fleetbase\Traits\HasPublicid;
|
|
9
9
|
use Fleetbase\Traits\HasUuid;
|
|
10
|
-
use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait;
|
|
11
10
|
|
|
12
11
|
class StoreLocation extends StorefrontModel
|
|
13
12
|
{
|
|
14
13
|
use HasUuid;
|
|
15
14
|
use HasPublicid;
|
|
16
15
|
use HasApiModelBehavior;
|
|
17
|
-
use SpatialTrait;
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* The type of public Id to generate.
|
|
@@ -28,7 +28,7 @@ class StorefrontOrderCanceled extends Notification
|
|
|
28
28
|
/**
|
|
29
29
|
* The order instance this notification is for.
|
|
30
30
|
*
|
|
31
|
-
* @var
|
|
31
|
+
* @var Order
|
|
32
32
|
*/
|
|
33
33
|
public $order;
|
|
34
34
|
|
|
@@ -63,7 +63,7 @@ class StorefrontOrderCanceled extends Notification
|
|
|
63
63
|
/**
|
|
64
64
|
* Get the mail representation of the notification.
|
|
65
65
|
*
|
|
66
|
-
* @return
|
|
66
|
+
* @return MailMessage
|
|
67
67
|
*/
|
|
68
68
|
public function toMail($notifiable)
|
|
69
69
|
{
|
|
@@ -10,7 +10,7 @@ class NetworkObserver
|
|
|
10
10
|
/**
|
|
11
11
|
* Handle the Network "updated" event.
|
|
12
12
|
*
|
|
13
|
-
* @param
|
|
13
|
+
* @param Network $network the Network that is updating
|
|
14
14
|
*/
|
|
15
15
|
public function updating(Network $network): void
|
|
16
16
|
{
|
|
@@ -17,7 +17,7 @@ class ProductObserver
|
|
|
17
17
|
/**
|
|
18
18
|
* Handle the Product "created" event.
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
20
|
+
* @param Product $product the Product that was created
|
|
21
21
|
*/
|
|
22
22
|
public function created(Product $product): void
|
|
23
23
|
{
|
|
@@ -41,7 +41,7 @@ class ProductObserver
|
|
|
41
41
|
/**
|
|
42
42
|
* Handle the Product "updated" event.
|
|
43
43
|
*
|
|
44
|
-
* @param
|
|
44
|
+
* @param Product $product the Product that was created
|
|
45
45
|
*/
|
|
46
46
|
public function updated(Product $product): void
|
|
47
47
|
{
|
|
@@ -96,6 +96,5 @@ class StorefrontServiceProvider extends CoreServiceProvider
|
|
|
96
96
|
$this->mergeConfigFrom(__DIR__ . '/../../config/database.connections.php', 'database.connections');
|
|
97
97
|
$this->mergeConfigFrom(__DIR__ . '/../../config/storefront.php', 'storefront');
|
|
98
98
|
$this->mergeConfigFrom(__DIR__ . '/../../config/api.php', 'storefront.api');
|
|
99
|
-
$this->mergeConfigFrom(__DIR__ . '/../../config/twilio-notification-channel.php', 'twilio-notification-channel');
|
|
100
99
|
}
|
|
101
100
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Rules;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Storefront\Models\Cart;
|
|
6
|
+
use Illuminate\Contracts\Validation\Rule;
|
|
7
|
+
|
|
8
|
+
class CartExists implements Rule
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Determine if the validation rule passes.
|
|
12
|
+
*
|
|
13
|
+
* @param string $attribute
|
|
14
|
+
*
|
|
15
|
+
* @return bool
|
|
16
|
+
*/
|
|
17
|
+
public function passes($attribute, $value)
|
|
18
|
+
{
|
|
19
|
+
return Cart::where(['public_id' => $attribute, 'unique_identifier' => $attribute])->exists();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get the validation error message.
|
|
24
|
+
*
|
|
25
|
+
* @return string
|
|
26
|
+
*/
|
|
27
|
+
public function message()
|
|
28
|
+
{
|
|
29
|
+
return 'Cart session does not exists.';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Rules;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\Contact;
|
|
6
|
+
use Illuminate\Contracts\Validation\Rule;
|
|
7
|
+
use Illuminate\Support\Str;
|
|
8
|
+
|
|
9
|
+
class CustomerExists implements Rule
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Determine if the validation rule passes.
|
|
13
|
+
*
|
|
14
|
+
* @param string $attribute
|
|
15
|
+
*
|
|
16
|
+
* @return bool
|
|
17
|
+
*/
|
|
18
|
+
public function passes($attribute, $value)
|
|
19
|
+
{
|
|
20
|
+
$value = Str::replaceFirst('customer', 'contact', $value);
|
|
21
|
+
|
|
22
|
+
return Contact::where('public_id', $value)->exists();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get the validation error message.
|
|
27
|
+
*
|
|
28
|
+
* @return string
|
|
29
|
+
*/
|
|
30
|
+
public function message()
|
|
31
|
+
{
|
|
32
|
+
return 'No customer found.';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Rules;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Storefront\Models\Gateway;
|
|
6
|
+
use Illuminate\Contracts\Validation\Rule;
|
|
7
|
+
|
|
8
|
+
class GatewayExists implements Rule
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Determine if the validation rule passes.
|
|
12
|
+
*
|
|
13
|
+
* @param string $attribute
|
|
14
|
+
*
|
|
15
|
+
* @return bool
|
|
16
|
+
*/
|
|
17
|
+
public function passes($attribute, $value)
|
|
18
|
+
{
|
|
19
|
+
if ($value === 'cash') {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return Gateway::where(['code' => $value])->exists();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get the validation error message.
|
|
28
|
+
*
|
|
29
|
+
* @return string
|
|
30
|
+
*/
|
|
31
|
+
public function message()
|
|
32
|
+
{
|
|
33
|
+
return 'No gateway by code provided exists.';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Rules;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\Place;
|
|
6
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
7
|
+
use Fleetbase\Storefront\Models\StoreLocation;
|
|
8
|
+
use Illuminate\Contracts\Validation\Rule;
|
|
9
|
+
use Illuminate\Support\Str;
|
|
10
|
+
|
|
11
|
+
class IsValidLocation implements Rule
|
|
12
|
+
{
|
|
13
|
+
/**
|
|
14
|
+
* Determine if the validation rule passes.
|
|
15
|
+
*
|
|
16
|
+
* @param string $attribute
|
|
17
|
+
*
|
|
18
|
+
* @return bool
|
|
19
|
+
*/
|
|
20
|
+
public function passes($attribute, $value)
|
|
21
|
+
{
|
|
22
|
+
// Validate Place id
|
|
23
|
+
if (Str::startsWith($value, 'place_')) {
|
|
24
|
+
return Place::where('public_id', $value)->exists();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Validate StoreLocation id
|
|
28
|
+
if (Str::startsWith($value, 'store_location_')) {
|
|
29
|
+
return StoreLocation::where('public_id', $value)->exists();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Validate object with coordinates
|
|
33
|
+
if (isset($value->coordinates)) {
|
|
34
|
+
return Utils::isCoordinates($value->coordinates);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Validate coordinates
|
|
38
|
+
if (Utils::isCoordinates($value)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get the validation error message.
|
|
47
|
+
*
|
|
48
|
+
* @return string
|
|
49
|
+
*/
|
|
50
|
+
public function message()
|
|
51
|
+
{
|
|
52
|
+
return 'Invalid :attribute.';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -10,6 +10,7 @@ use Fleetbase\Storefront\Models\Network;
|
|
|
10
10
|
use Fleetbase\Storefront\Models\Product;
|
|
11
11
|
use Fleetbase\Storefront\Models\Store;
|
|
12
12
|
use Fleetbase\Storefront\Notifications\StorefrontOrderCreated;
|
|
13
|
+
use Fleetbase\Support\Utils;
|
|
13
14
|
use Illuminate\Support\Facades\Notification;
|
|
14
15
|
use Illuminate\Support\Facades\Redis;
|
|
15
16
|
use Illuminate\Support\Str;
|
|
@@ -92,7 +93,7 @@ class Storefront
|
|
|
92
93
|
if ($token) {
|
|
93
94
|
$accessToken = PersonalAccessToken::findToken($token);
|
|
94
95
|
|
|
95
|
-
if ($accessToken &&
|
|
96
|
+
if ($accessToken && Str::isUuid($accessToken->name)) {
|
|
96
97
|
$customer = Contact::where('uuid', $accessToken->name)->first();
|
|
97
98
|
|
|
98
99
|
if ($customer) {
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
return [
|
|
4
|
-
'username' => env('TWILIO_USERNAME'), // optional when using auth token
|
|
5
|
-
'password' => env('TWILIO_PASSWORD'), // optional when using auth token
|
|
6
|
-
'auth_token' => env('TWILIO_TOKEN'), // optional when using username and password
|
|
7
|
-
'account_sid' => env('TWILIO_SID'),
|
|
8
|
-
|
|
9
|
-
'from' => env('TWILIO_FROM'), // optional
|
|
10
|
-
'alphanumeric_sender' => env('TWILIO_ALPHA_SENDER'),
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* See https://www.twilio.com/docs/sms/services.
|
|
14
|
-
*/
|
|
15
|
-
'sms_service_sid' => env('TWILIO_SMS_SERVICE_SID'),
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Specify a number where all calls/messages should be routed. This can be used in development/staging environments
|
|
19
|
-
* for testing.
|
|
20
|
-
*/
|
|
21
|
-
'debug_to' => env('TWILIO_DEBUG_TO'),
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* If an exception is thrown with one of these error codes, it will be caught & suppressed.
|
|
25
|
-
* To replicate the 2.x behaviour, specify '*' in the array, which will cause all exceptions to be suppressed.
|
|
26
|
-
* Suppressed errors will not be logged or reported, but the `NotificationFailed` event will be emitted.
|
|
27
|
-
*
|
|
28
|
-
* @see https://www.twilio.com/docs/api/errors
|
|
29
|
-
*/
|
|
30
|
-
'ignored_error_codes' => [
|
|
31
|
-
21608, // The 'to' phone number provided is not yet verified for this account.
|
|
32
|
-
21211, // Invalid 'To' Phone Number
|
|
33
|
-
21614, // 'To' number is not a valid mobile number
|
|
34
|
-
21408, // Permission to send an SMS has not been enabled for the region indicated by the 'To' number
|
|
35
|
-
],
|
|
36
|
-
];
|