@fleetbase/storefront-engine 0.3.0 → 0.3.2

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.
@@ -44,8 +44,8 @@ export default class ScheduleManagerComponent extends Component {
44
44
  });
45
45
 
46
46
  this.modalsManager.show('modals/add-store-hours', {
47
- title: this.intl.t('storefront.component.schedule-manager.add-new-hours-for-day', { Day: day }),
48
- acceptButtonText: this.intl.t('storefront.component.schedule-manager-add-hours'),
47
+ title: this.intl.t('storefront.component.schedule-manager.add-new-hours-for-day', { day: day }),
48
+ acceptButtonText: this.intl.t('storefront.component.schedule-manager.add-hours'),
49
49
  acceptButtonIcon: 'save',
50
50
  hours,
51
51
  confirm: (modal) => {
@@ -49,6 +49,13 @@ export default class NetworksIndexNetworkIndexController extends Controller {
49
49
  */
50
50
  @service intl;
51
51
 
52
+ /**
53
+ * Store service to handle file uploads and other network requests.
54
+ *
55
+ * @property {Service} store
56
+ */
57
+ @service store;
58
+
52
59
  /**
53
60
  * Proof of delivery methods.
54
61
  *
@@ -89,7 +96,7 @@ export default class NetworksIndexNetworkIndexController extends Controller {
89
96
  this.model
90
97
  .save()
91
98
  .then(() => {
92
- this.notifications.success(this.intl.t('storefront.controllers.networks.index.change-network-saved'));
99
+ this.notifications.success(this.intl.t('storefront.networks.index.network.index.change-network-saved'));
93
100
  })
94
101
  .catch((error) => {
95
102
  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.category.new.warning-only-select-an-image-file-to-be-primary'));
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.category.new.made-the-primary-success-image', { fileName: file.original_filename }));
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 @wrapperClass="mb-0 mt-2" @name={{t "storefront.networks.index.network.index.general-network-settings-form.config-switches.proof-of-delivery-method"}}>
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.gateways as |gateway|}}
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.0",
3
+ "version": "0.3.2",
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.3",
26
- "fleetbase/fleetops-api": "^0.4.9",
25
+ "fleetbase/core-api": "^1.4.9",
26
+ "fleetbase/fleetops-api": "^0.4.15",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "Storefront",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Headless Commerce & Marketplace Extension for Fleetbase",
5
5
  "repository": "https://github.com/fleetbase/storefront",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetbase/storefront-engine",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
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.10",
48
- "@fleetbase/fleetops-data": "^0.1.8",
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",
@@ -3,6 +3,8 @@
3
3
  namespace Fleetbase\Storefront\Expansions;
4
4
 
5
5
  use Fleetbase\Build\Expansion;
6
+ use Fleetbase\FleetOps\Models\Entity;
7
+ use Fleetbase\Storefront\Models\Product;
6
8
 
7
9
  class EntityExpansion implements Expansion
8
10
  {
@@ -13,18 +15,18 @@ class EntityExpansion implements Expansion
13
15
  */
14
16
  public static function target()
15
17
  {
16
- return \Fleetbase\FleetOps\Models\Entity::class;
18
+ return Entity::class;
17
19
  }
18
20
 
19
21
  /**
20
22
  * Create a new Entity from a Storefront Product.
21
23
  *
22
- * @return \Fleetbase\FleetOps\Models\Entity
24
+ * @return Entity
23
25
  */
24
26
  public function fromStorefrontProduct()
25
27
  {
26
- return static function (\Fleetbase\Storefront\Models\Product $product) {
27
- return new static([
28
+ return static function (Product $product) {
29
+ return new Entity([
28
30
  'company_uuid' => session('company'),
29
31
  'photo_uuid' => $product->primary_image_uuid,
30
32
  'internal_id' => $product->public_id,
@@ -15,7 +15,7 @@ class CartController extends Controller
15
15
  *
16
16
  * @return \Illuminate\Http\Response
17
17
  */
18
- public function retrieve(?string $uniqueId = null, Request $request)
18
+ public function retrieve(string $uniqueId = null, Request $request)
19
19
  {
20
20
  $cart = Cart::retrieve($uniqueId, true);
21
21
 
@@ -17,6 +17,7 @@ use Fleetbase\Storefront\Http\Requests\CaptureOrderRequest;
17
17
  use Fleetbase\Storefront\Http\Requests\InitializeCheckoutRequest;
18
18
  use Fleetbase\Storefront\Models\Cart;
19
19
  use Fleetbase\Storefront\Models\Checkout;
20
+ use Fleetbase\Storefront\Models\Customer;
20
21
  use Fleetbase\Storefront\Models\Gateway;
21
22
  use Fleetbase\Storefront\Models\Product;
22
23
  use Fleetbase\Storefront\Models\Store;
@@ -53,7 +54,7 @@ class CheckoutController extends Controller
53
54
  // find and validate cart session
54
55
  $cart = Cart::retrieve($cartId);
55
56
  $gateway = Storefront::findGateway($gatewayCode);
56
- $customer = Contact::findFromCustomerId($customerId);
57
+ $customer = Customer::findFromCustomerId($customerId);
57
58
  $serviceQuote = ServiceQuote::select(['amount', 'meta', 'uuid', 'public_id'])->where('public_id', $serviceQuoteId)->first();
58
59
 
59
60
  // handle cash orders
@@ -113,7 +114,7 @@ class CheckoutController extends Controller
113
114
  'gateway_uuid' => $gateway->uuid ?? null,
114
115
  'service_quote_uuid' => $serviceQuote->uuid,
115
116
  'owner_uuid' => $customer->uuid,
116
- 'owner_type' => 'contact',
117
+ 'owner_type' => 'fleet-ops:contact',
117
118
  'amount' => $amount,
118
119
  'currency' => $currency,
119
120
  'is_cod' => true,
@@ -187,7 +188,7 @@ class CheckoutController extends Controller
187
188
  'gateway_uuid' => $gateway->uuid,
188
189
  'service_quote_uuid' => $serviceQuote->uuid,
189
190
  'owner_uuid' => $customer->uuid,
190
- 'owner_type' => 'contact',
191
+ 'owner_type' => 'fleet-ops:contact',
191
192
  'amount' => $amount,
192
193
  'currency' => $currency,
193
194
  'is_pickup' => $isPickup,
@@ -249,7 +250,7 @@ class CheckoutController extends Controller
249
250
  'gateway_uuid' => $gateway->uuid,
250
251
  'service_quote_uuid' => $serviceQuote->uuid,
251
252
  'owner_uuid' => $customer->uuid,
252
- 'owner_type' => 'contact',
253
+ 'owner_type' => 'fleet-ops:contact',
253
254
  'amount' => $amount,
254
255
  'currency' => $currency,
255
256
  'is_pickup' => $isPickup,
@@ -345,7 +346,7 @@ class CheckoutController extends Controller
345
346
  $transaction = Transaction::create([
346
347
  'company_uuid' => session('company'),
347
348
  'customer_uuid' => $customer->uuid,
348
- 'customer_type' => 'contact',
349
+ 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
349
350
  'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(),
350
351
  'gateway' => $gateway->code,
351
352
  'gateway_uuid' => $gateway->uuid,
@@ -458,18 +459,7 @@ class CheckoutController extends Controller
458
459
  // create entities
459
460
  foreach ($cart->items as $cartItem) {
460
461
  $product = Product::where('public_id', $cartItem->product_id)->first();
461
- $entity = Entity::fromStorefrontProduct($product)->fill([
462
- 'company_uuid' => session('company'),
463
- 'payload_uuid' => $payload->uuid,
464
- 'customer_uuid' => $customer->uuid,
465
- 'customer_type' => 'contact',
466
- ])->setMetas([
467
- 'variants' => $cartItem->variants,
468
- 'addons' => $cartItem->addons,
469
- 'subtotal' => $cartItem->subtotal,
470
- 'quantity' => $cartItem->quantity,
471
- 'scheduled_at' => $cartItem->scheduled_at ?? null,
472
- ]);
462
+ $entity = Entity::fromStorefrontProduct($product);
473
463
 
474
464
  $entity->save();
475
465
  }
@@ -505,7 +495,7 @@ class CheckoutController extends Controller
505
495
  'company_uuid' => $store->company_uuid ?? session('company'),
506
496
  'payload_uuid' => $payload->uuid,
507
497
  'customer_uuid' => $customer->uuid,
508
- 'customer_type' => 'contact',
498
+ 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
509
499
  'transaction_uuid' => $transaction->uuid,
510
500
  'adhoc' => $about->isOption('auto_dispatch'),
511
501
  'type' => 'storefront',
@@ -525,6 +515,8 @@ class CheckoutController extends Controller
525
515
  // create order
526
516
  $order = Order::create($orderInput);
527
517
 
518
+ info('Order created', $order->toArray());
519
+
528
520
  // notify order creation
529
521
  Storefront::alertNewOrder($order);
530
522
 
@@ -610,7 +602,7 @@ class CheckoutController extends Controller
610
602
  $transaction = Transaction::create([
611
603
  'company_uuid' => session('company'),
612
604
  'customer_uuid' => $customer->uuid,
613
- 'customer_type' => 'contact',
605
+ 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
614
606
  'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(),
615
607
  'gateway' => $gateway->code,
616
608
  'gateway_uuid' => $gateway->uuid,
@@ -706,7 +698,7 @@ class CheckoutController extends Controller
706
698
  'company_uuid' => $store->company_uuid,
707
699
  'payload_uuid' => $payload->uuid,
708
700
  'customer_uuid' => $customer->uuid,
709
- 'customer_type' => 'contact',
701
+ 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
710
702
  ])->setMetas([
711
703
  'variants' => $cartItem->variants,
712
704
  'addons' => $cartItem->addons,
@@ -746,7 +738,7 @@ class CheckoutController extends Controller
746
738
  'company_uuid' => $store->company_uuid,
747
739
  'payload_uuid' => $payload->uuid,
748
740
  'customer_uuid' => $customer->uuid,
749
- 'customer_type' => 'contact',
741
+ 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
750
742
  'transaction_uuid' => $transaction->uuid,
751
743
  'adhoc' => $about->isOption('auto_dispatch'),
752
744
  'type' => 'storefront',
@@ -811,7 +803,7 @@ class CheckoutController extends Controller
811
803
  'company_uuid' => session('company'),
812
804
  'payload_uuid' => $payload->uuid,
813
805
  'customer_uuid' => $customer->uuid,
814
- 'customer_type' => 'contact',
806
+ 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
815
807
  ])->setMetas([
816
808
  'variants' => $cartItem->variants,
817
809
  'addons' => $cartItem->addons,
@@ -849,7 +841,7 @@ class CheckoutController extends Controller
849
841
  'company_uuid' => session('company'),
850
842
  'payload_uuid' => $payload->uuid,
851
843
  'customer_uuid' => $customer->uuid,
852
- 'customer_type' => 'contact',
844
+ 'customer_type' => Utils::getMutationType('fleet-ops:contact'),
853
845
  'transaction_uuid' => $transaction->uuid,
854
846
  'adhoc' => $about->isOption('auto_dispatch'),
855
847
  'type' => 'storefront',
@@ -462,7 +462,7 @@ class CustomerController extends Controller
462
462
  /**
463
463
  * Patches phone number with international code.
464
464
  */
465
- public static function phone(?string $phone = null): string
465
+ public static function phone(string $phone = null): string
466
466
  {
467
467
  if ($phone === null) {
468
468
  $phone = request()->input('phone');
@@ -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($sandbox));
112
+ $gateways->push(Gateway::cash(['sandbox'=>$sandbox]));
113
113
  }
114
114
 
115
115
  return GatewayResource::collection($gateways);
@@ -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(
@@ -55,7 +55,7 @@ class Product extends FleetbaseResource
55
55
  ];
56
56
  }
57
57
 
58
- public function mapHours(?\Illuminate\Database\Eloquent\Collection $hours = null): array
58
+ public function mapHours(\Illuminate\Database\Eloquent\Collection $hours = null): array
59
59
  {
60
60
  if (empty($hours)) {
61
61
  return [];
@@ -79,7 +79,7 @@ class Product extends FleetbaseResource
79
79
  );
80
80
  }
81
81
 
82
- public function mapFiles(?\Illuminate\Database\Eloquent\Collection $files = null, $contentType = 'image')
82
+ public function mapFiles(\Illuminate\Database\Eloquent\Collection $files = null, $contentType = 'image')
83
83
  {
84
84
  return collect($files)->map(function ($file) use ($contentType) {
85
85
  if (!Str::contains($file->content_type, $contentType)) {
@@ -90,7 +90,7 @@ class Product extends FleetbaseResource
90
90
  })->filter()->values();
91
91
  }
92
92
 
93
- public function mapAddonCategories(?\Illuminate\Database\Eloquent\Collection $addonCategories = null)
93
+ public function mapAddonCategories(\Illuminate\Database\Eloquent\Collection $addonCategories = null)
94
94
  {
95
95
  return collect($addonCategories)->map(function ($addonCategory) {
96
96
  $addons = data_get($addonCategory, 'category.addons', []);
@@ -120,7 +120,7 @@ class Product extends FleetbaseResource
120
120
  });
121
121
  }
122
122
 
123
- public function mapProductAddons(?\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
123
+ public function mapProductAddons(\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
124
124
  {
125
125
  return collect($addons)->map(function ($addon) use ($excluded) {
126
126
  if (is_array($excluded) && in_array($addon->uuid, $excluded)) {
@@ -157,7 +157,7 @@ class Product extends FleetbaseResource
157
157
  })->filter()->values();
158
158
  }
159
159
 
160
- public function mapVariants(?\Illuminate\Database\Eloquent\Collection $variants = null)
160
+ public function mapVariants(\Illuminate\Database\Eloquent\Collection $variants = null)
161
161
  {
162
162
  return collect($variants)->map(function ($variant) {
163
163
  $productVariantArr = [
@@ -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
  }
@@ -587,7 +587,7 @@ class Cart extends StorefrontModel
587
587
  *
588
588
  * @return \Fleetbase\Models\Storefront\Cart
589
589
  */
590
- public function updateCurrency(?string $currencyCode = null, $save = false)
590
+ public function updateCurrency(string $currencyCode = null, $save = false)
591
591
  {
592
592
  $this->attributes['currency'] = $currencyCode ?? session('storefront_currency');
593
593
 
@@ -3,9 +3,9 @@
3
3
  namespace Fleetbase\Storefront\Models;
4
4
 
5
5
  use Fleetbase\Casts\Json;
6
- use Fleetbase\FleetOps\Support\Utils;
6
+ use Fleetbase\FleetOps\Models\ServiceQuote;
7
7
  use Fleetbase\Models\Company;
8
- use Fleetbase\Models\ServiceQuote;
8
+ use Fleetbase\Support\Utils;
9
9
  use Fleetbase\Traits\HasOptionsAttributes;
10
10
  use Fleetbase\Traits\HasPublicid;
11
11
  use Fleetbase\Traits\HasUuid;
@@ -220,7 +220,7 @@ class Network extends StorefrontModel
220
220
  /**
221
221
  * Adds a new store to the network.
222
222
  */
223
- public function addStore(Store $store, ?Category $category = null): NetworkStore
223
+ public function addStore(Store $store, Category $category = null): NetworkStore
224
224
  {
225
225
  return NetworkStore::updateOrCreate(
226
226
  [
@@ -241,7 +241,7 @@ class Network extends StorefrontModel
241
241
  * @param File|string|null $icon
242
242
  * @param string $iconColor
243
243
  */
244
- public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
244
+ public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
245
245
  {
246
246
  $iconFile = null;
247
247
  $iconName = null;
@@ -276,7 +276,7 @@ class Network extends StorefrontModel
276
276
  * @param File|string|null $icon
277
277
  * @param string $iconColor
278
278
  */
279
- public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
279
+ public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
280
280
  {
281
281
  $existingCategory = Category::where(['company_uuid' => $this->company_uuid, 'owner_uuid' => $this->uuid, 'name' => $name])->first();
282
282
 
@@ -360,7 +360,7 @@ class Store extends StorefrontModel
360
360
  * @param File|string|null $icon
361
361
  * @param string $iconColor
362
362
  */
363
- 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
364
364
  {
365
365
  $iconFile = null;
366
366
  $iconName = null;
@@ -397,7 +397,7 @@ class Store extends StorefrontModel
397
397
  * @param File|string|null $icon
398
398
  * @param string $iconColor
399
399
  */
400
- 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
401
401
  {
402
402
  $existingCategory = Category::where(['company_uuid' => $this->company_uuid, 'owner_uuid' => $this->uuid, 'name' => $name])->first();
403
403
 
@@ -411,7 +411,7 @@ class Store extends StorefrontModel
411
411
  /**
412
412
  * Creates a new product in the store.
413
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
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
415
415
  {
416
416
  return Product::create(
417
417
  [
@@ -438,7 +438,7 @@ class Store extends StorefrontModel
438
438
  );
439
439
  }
440
440
 
441
- public function createLocation($location, ?string $name = null, ?User $createdBy): ?StoreLocation
441
+ public function createLocation($location, string $name = null, ?User $createdBy): ?StoreLocation
442
442
  {
443
443
  $place = Place::createFromMixed($location);
444
444
 
@@ -3,6 +3,7 @@
3
3
  namespace Fleetbase\Storefront\Models;
4
4
 
5
5
  use Fleetbase\FleetOps\Models\Place;
6
+ use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait;
6
7
  use Fleetbase\Models\User;
7
8
  use Fleetbase\Traits\HasApiModelBehavior;
8
9
  use Fleetbase\Traits\HasPublicid;
@@ -13,6 +14,7 @@ class StoreLocation extends StorefrontModel
13
14
  use HasUuid;
14
15
  use HasPublicid;
15
16
  use HasApiModelBehavior;
17
+ use SpatialTrait;
16
18
 
17
19
  /**
18
20
  * The type of public Id to generate.
@@ -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
  }
@@ -23,7 +23,7 @@ class Metrics
23
23
  protected Company $company;
24
24
  protected array $metrics = [];
25
25
 
26
- public static function new(Company $company, ?\DateTime $start = null, ?\DateTime $end = null): Metrics
26
+ public static function new(Company $company, \DateTime $start = null, \DateTime $end = null): Metrics
27
27
  {
28
28
  $start = $start === null ? Carbon::create(1900)->toDateTime() : $start;
29
29
  $end = $end === null ? Carbon::tomorrow()->toDateTime() : $end;
@@ -31,7 +31,7 @@ class Metrics
31
31
  return (new static())->setCompany($company)->between($start, $end);
32
32
  }
33
33
 
34
- public static function forCompany(Company $company, ?\DateTime $start = null, ?\DateTime $end = null): Metrics
34
+ public static function forCompany(Company $company, \DateTime $start = null, \DateTime $end = null): Metrics
35
35
  {
36
36
  return static::new($company, $start, $end);
37
37
  }
@@ -104,7 +104,7 @@ class Metrics
104
104
  return $this;
105
105
  }
106
106
 
107
- public function totalProducts(?callable $callback = null): Metrics
107
+ public function totalProducts(callable $callback = null): Metrics
108
108
  {
109
109
  $query = Product::where('company_uuid', $this->company->uuid);
110
110
 
@@ -117,7 +117,7 @@ class Metrics
117
117
  return $this->set('total_products', $data);
118
118
  }
119
119
 
120
- public function totalStores(?callable $callback = null): Metrics
120
+ public function totalStores(callable $callback = null): Metrics
121
121
  {
122
122
  $query = Store::where('company_uuid', $this->company->uuid);
123
123
 
@@ -130,7 +130,7 @@ class Metrics
130
130
  return $this->set('total_stores', $data);
131
131
  }
132
132
 
133
- public function totalNetworks(?callable $callback = null): Metrics
133
+ public function totalNetworks(callable $callback = null): Metrics
134
134
  {
135
135
  $query = Network::where('company_uuid', $this->company->uuid);
136
136
 
@@ -143,7 +143,7 @@ class Metrics
143
143
  return $this->set('total_networks', $data);
144
144
  }
145
145
 
146
- public function ordersInProgress(?callable $callback = null): Metrics
146
+ public function ordersInProgress(callable $callback = null): Metrics
147
147
  {
148
148
  $query = Order::where('company_uuid', $this->company->uuid)
149
149
  ->whereBetween('created_at', [$this->start, $this->end])
@@ -159,7 +159,7 @@ class Metrics
159
159
  return $this->set('orders_in_progress', $data);
160
160
  }
161
161
 
162
- public function ordersCompleted(?callable $callback = null): Metrics
162
+ public function ordersCompleted(callable $callback = null): Metrics
163
163
  {
164
164
  $query = Order::where('company_uuid', $this->company->uuid)
165
165
  ->whereBetween('created_at', [$this->start, $this->end])
@@ -175,7 +175,7 @@ class Metrics
175
175
  return $this->set('orders_completed', $data);
176
176
  }
177
177
 
178
- public function ordersCanceled(?callable $callback = null): Metrics
178
+ public function ordersCanceled(callable $callback = null): Metrics
179
179
  {
180
180
  $query = Order::where('company_uuid', $this->company->uuid)
181
181
  ->whereBetween('created_at', [$this->start, $this->end])
@@ -12,7 +12,7 @@ class QPay
12
12
  private array $requestOptions = [];
13
13
  private Client $client;
14
14
 
15
- public function __construct(?string $username = null, ?string $password = null, ?string $callbackUrl = null)
15
+ public function __construct(string $username = null, string $password = null, string $callbackUrl = null)
16
16
  {
17
17
  $this->callbackUrl = $callbackUrl;
18
18
  $this->requestOptions = [
@@ -60,7 +60,7 @@ class QPay
60
60
  return $this;
61
61
  }
62
62
 
63
- public static function instance(?string $username = null, ?string $password = null, ?string $callbackUrl = null): QPay
63
+ public static function instance(string $username = null, string $password = null, string $callbackUrl = null): QPay
64
64
  {
65
65
  return new static($username, $password, $callbackUrl);
66
66
  }
@@ -120,7 +120,7 @@ class QPay
120
120
  return $this;
121
121
  }
122
122
 
123
- public function setAuthToken(?string $accessToken = null): QPay
123
+ public function setAuthToken(string $accessToken = null): QPay
124
124
  {
125
125
  if ($accessToken) {
126
126
  $this->useBearerToken($accessToken);
@@ -136,7 +136,7 @@ class QPay
136
136
  return $this;
137
137
  }
138
138
 
139
- public function createSimpleInvoice(int $amount, ?string $invoiceCode = '', ?string $invoiceDescription = '', ?string $invoiceReceiverCode = '', ?string $senderInvoiceNo = '', ?string $callbackUrl = null)
139
+ public function createSimpleInvoice(int $amount, ?string $invoiceCode = '', ?string $invoiceDescription = '', ?string $invoiceReceiverCode = '', ?string $senderInvoiceNo = '', string $callbackUrl = null)
140
140
  {
141
141
  if (!$callbackUrl && $this->hasCallbackUrl()) {
142
142
  $callbackUrl = $this->callbackUrl;
@@ -39,7 +39,7 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
39
39
  // storefront/v1/checkouts
40
40
  $router->group(['prefix' => 'checkouts'], function () use ($router) {
41
41
  $router->get('before', 'CheckoutController@beforeCheckout');
42
- $router->get('capture', 'CheckoutController@captureOrder');
42
+ $router->post('capture', 'CheckoutController@captureOrder');
43
43
  });
44
44
 
45
45
  // storefront/v1/service-quotes
@@ -105,7 +105,7 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
105
105
  */
106
106
  $router->prefix(config('storefront.api.routing.internal_prefix', 'int'))->group(
107
107
  function ($router) {
108
- $router->group(['prefix' => 'int/v1', 'middleware' => ['internal.cors']], function () use ($router) {
108
+ $router->group(['prefix' => 'v1'], function () use ($router) {
109
109
  $router->get('networks/find/{id}', 'NetworkController@findNetwork');
110
110
  });
111
111
 
@@ -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
- ];