@fleetbase/storefront-engine 0.3.12 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/addon/components/add-product-as-entity-button.js +3 -3
  2. package/addon/components/modals/create-first-store.hbs +3 -1
  3. package/addon/components/widget/storefront-key-metrics.hbs +1 -1
  4. package/addon/controllers/application.js +1 -1
  5. package/addon/controllers/products/index/category/edit.js +1 -0
  6. package/addon/controllers/products/index/category/new.js +6 -2
  7. package/addon/routes/application.js +14 -3
  8. package/addon/routes/customers/index/edit.js +14 -1
  9. package/addon/routes/customers/index/view.js +11 -0
  10. package/addon/routes/customers/index.js +11 -0
  11. package/addon/routes/networks/index/network.js +11 -0
  12. package/addon/routes/networks/index.js +11 -0
  13. package/addon/routes/orders/index/edit.js +14 -1
  14. package/addon/routes/orders/index/new.js +14 -1
  15. package/addon/routes/orders/index/view.js +10 -0
  16. package/addon/routes/orders/index.js +11 -0
  17. package/addon/routes/products/index/category/edit.js +11 -0
  18. package/addon/routes/products/index/category/new.js +15 -1
  19. package/addon/routes/products/index/category.js +12 -1
  20. package/addon/routes/products/index/index.js +11 -0
  21. package/addon/routes/products/index.js +11 -0
  22. package/addon/routes/settings/index.js +11 -0
  23. package/addon/services/storefront.js +35 -74
  24. package/addon/templates/application.hbs +31 -5
  25. package/addon/templates/customers/index.hbs +1 -1
  26. package/addon/templates/networks/index.hbs +4 -3
  27. package/addon/templates/orders/index.hbs +2 -2
  28. package/addon/templates/products/index/category/new.hbs +326 -245
  29. package/addon/templates/products/index/category.hbs +6 -9
  30. package/addon/templates/products/index/index.hbs +2 -2
  31. package/addon/templates/products/index.hbs +11 -5
  32. package/addon/templates/settings/index.hbs +1 -0
  33. package/composer.json +3 -3
  34. package/extension.json +1 -1
  35. package/package.json +8 -7
  36. package/server/src/Auth/Schemas/Storefront.php +97 -3
  37. package/server/src/Http/Controllers/v1/CartController.php +1 -1
  38. package/server/src/Http/Controllers/v1/CustomerController.php +1 -1
  39. package/server/src/Http/Resources/Product.php +5 -5
  40. package/server/src/Models/Cart.php +1 -1
  41. package/server/src/Models/Network.php +3 -3
  42. package/server/src/Models/Store.php +4 -4
  43. package/server/src/Support/Metrics.php +8 -8
  44. package/server/src/Support/QPay.php +4 -4
@@ -1,17 +1,14 @@
1
1
  <Layout::Section::Header @title={{concat this.category.name " Products"}} @titleClass="truncate" @searchQuery={{this.query}} @onSearch={{perform this.search}}>
2
- {{!-- <Button @type="default" @text="Edit this category" @textClass="truncate" @icon="edit" @onClick={{fn this.editCategory this.category}} @disabled={{not this.category}} @wrapperClass="mr-2" />
3
- <Button @type="danger" @text="Delete this category" @textClass="truncate" @icon="trash" @onClick={{this.deleteCategory}} @disabled={{not this.category}} /> --}}
4
-
5
2
  {{#if this.category}}
6
- <DropdownButton @icon="gear" @text="Category" @type="default" @size="sm" @contentClass="dropdown-menu" as |dd|>
7
- <div class="next-dd-menu">
3
+ <DropdownButton @icon="gear" @text="Category" @type="default" @size="sm" @contentClass="dropdown-menu" @renderInPlace={{true}} as |dd|>
4
+ <div class="next-dd-menu mt-1 mx-0" aria-labelledby="user-menu">
8
5
  <div class="px-1">
9
- <a href="#" class="next-dd-item" {{on "click" (dropdown-fn dd this.editCategory this.category)}}>
6
+ <a href="#" class="next-dd-item" disabled={{cannot "storefront update product-category"}} {{on "click" (dropdown-fn dd this.editCategory this.category)}}>
10
7
  Edit this category...
11
8
  </a>
12
9
  </div>
13
10
  <div class="px-1">
14
- <a href="#" class="text-red-500 next-dd-item" {{on "click" (dropdown-fn dd this.deleteCategory)}}>
11
+ <a href="#" class="text-red-500 next-dd-item" disabled={{cannot "storefront delete product-category"}} {{on "click" (dropdown-fn dd this.deleteCategory)}}>
15
12
  Delete this category...
16
13
  </a>
17
14
  </div>
@@ -32,11 +29,11 @@
32
29
  <p class="text-sm truncate">{{product.description}}</p>
33
30
  <p class="mb-2 text-sm text-green-400">{{format-currency product.price product.currency}}</p>
34
31
  <div class="flex items-center justify-evenly space-x-4">
35
- <LinkTo @route="products.index.category.edit" @model={{product}} class="text-sm">
32
+ <LinkTo @route="products.index.category.edit" @model={{product}} disabled={{cannot "storefront update product"}} class="text-sm">
36
33
  <FaIcon @icon="pencil" class="mr-1" />
37
34
  <span class="destroy-action">Edit</span>
38
35
  </LinkTo>
39
- <a href="javascript:;" class="destroy-action text-sm" {{on "click" (fn this.deleteProduct product)}}>
36
+ <a href="javascript:;" class="destroy-action text-sm" disabled={{cannot "storefront delete product"}} {{on "click" (fn this.deleteProduct product)}}>
40
37
  <FaIcon @icon="trash" class="text-red-500 mr-1" />
41
38
  <span class="destroy-action">Delete</span>
42
39
  </a>
@@ -13,11 +13,11 @@
13
13
  <p class="text-sm truncate">{{product.description}}</p>
14
14
  <p class="mb-2 text-sm text-green-400">{{format-currency product.price product.currency}}</p>
15
15
  <div class="flex items-center justify-evenly space-x-4">
16
- <LinkTo @route="products.index.index.edit" @model={{product}} class="text-sm">
16
+ <LinkTo @route="products.index.index.edit" @model={{product}} disabled={{cannot "storefront update product"}} class="text-sm">
17
17
  <FaIcon @icon="pencil" class="mr-1" />
18
18
  <span class="destroy-action">Edit</span>
19
19
  </LinkTo>
20
- <a href="javascript:;" class="destroy-action text-sm" {{on "click" (fn this.deleteProduct product)}}>
20
+ <a href="javascript:;" class="destroy-action text-sm" disabled={{cannot "storefront delete product"}} {{on "click" (fn this.deleteProduct product)}}>
21
21
  <FaIcon @icon="trash" class="text-red-500 mr-1" />
22
22
  <span class="destroy-action">Delete</span>
23
23
  </a>
@@ -1,17 +1,18 @@
1
1
  <Layout::Section::Header @title={{t "storefront.common.product"}}>
2
- <Button @type="magic" @icon="tags" @text={{t "storefront.products.index.manage-addons"}} class="mr-2 flex-shrink-0" @onClick={{this.manageAddons}} />
2
+ <Button @type="magic" @icon="tags" @text={{t "storefront.products.index.manage-addons"}} class="mr-2 flex-shrink-0" @permission="storefront list product-addon" @onClick={{this.manageAddons}} />
3
3
  <Button
4
4
  @type="primary"
5
5
  @icon="plus"
6
6
  @iconPrefix="fas"
7
7
  @text={{t "storefront.common.new"}}
8
- class="mr-2 flex-shrink-0"
9
8
  @onClick={{this.createNewProduct}}
10
9
  @disabled={{not this.category}}
11
10
  @helpText={{unless this.category "Select a category to create a product within"}}
11
+ @permission="storefront create product"
12
+ class="mr-2 flex-shrink-0"
12
13
  />
13
- <Button @icon="file-import" @text={{t "storefront.common.import"}} class="mr-2" @wrapperClass="hidden lg:flex flex-shrink-0" @onClick={{this.importProducts}} />
14
- <Button @icon="long-arrow-up" @iconClass="rotate-icon-45" @wrapperClass="hidden lg:flex flex-shrink-0" @text={{t "storefront.common.export"}} />
14
+ <Button @icon="file-import" @text={{t "storefront.common.import"}} class="mr-2" @wrapperClass="hidden lg:flex flex-shrink-0" @permission="storefront import product" @onClick={{this.importProducts}} />
15
+ <Button @icon="long-arrow-up" @iconClass="rotate-icon-45" @wrapperClass="hidden lg:flex flex-shrink-0" @permission="storefront export product" @text={{t "storefront.common.export"}} />
15
16
  </Layout::Section::Header>
16
17
 
17
18
  <Layout::Section::Body class="section-content flex flex-col lg:flex-row">
@@ -28,7 +29,12 @@
28
29
  @customTopItemClass="border-t border-gray-200 dark:border-gray-700"
29
30
  as |category|
30
31
  >
31
- <a href="javascript:;" class="aside-item-link cursor-pointer flex w-full md:px-6 md:py-5" {{on "click" (fn this.switchCategory category)}}>
32
+ <a
33
+ href="javascript:;"
34
+ class="aside-item-link cursor-pointer flex w-full md:px-6 md:py-5"
35
+ disabled={{cannot "storefront list product"}}
36
+ {{on "click" (fn this.switchCategory category)}}
37
+ >
32
38
  <div class="flex items-center justify-between">
33
39
  <div>
34
40
  <h4>{{category.name}}</h4>
@@ -327,6 +327,7 @@
327
327
  @size="lg"
328
328
  @isLoading={{this.isLoading}}
329
329
  @onClick={{this.saveSettings}}
330
+ @permission="storefront update settings"
330
331
  />
331
332
  </div>
332
333
  </div>
package/composer.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbase/storefront-api",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
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.27",
26
- "fleetbase/fleetops-api": "^0.5.3",
25
+ "fleetbase/core-api": "^1.5.3",
26
+ "fleetbase/fleetops-api": "^0.5.6",
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.12",
3
+ "version": "0.3.14",
4
4
  "description": "Headless Commerce & Marketplace Extension for Fleetbase",
5
5
  "repository": "https://github.com/fleetbase/storefront",
6
6
  "license": "AGPL-3.0-or-later",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetbase/storefront-engine",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
4
4
  "description": "Headless Commerce & Marketplace Extension for Fleetbase",
5
5
  "fleetbase": {
6
6
  "route": "storefront",
@@ -43,13 +43,14 @@
43
43
  "publish:github": "npm config set '@fleetbase:registry' https://npm.pkg.github.com/ && npm publish"
44
44
  },
45
45
  "dependencies": {
46
- "@fleetbase/ember-core": "^0.2.12",
47
- "@fleetbase/ember-ui": "^0.2.18",
46
+ "@fleetbase/ember-core": "^0.2.17",
47
+ "@fleetbase/ember-ui": "^0.2.24",
48
48
  "@fleetbase/fleetops-data": "^0.1.17",
49
49
  "@babel/core": "^7.23.2",
50
- "@fortawesome/ember-fontawesome": "^0.4.1",
51
- "@fortawesome/fontawesome-svg-core": "^6.4.0",
52
- "@fortawesome/free-solid-svg-icons": "^6.4.0",
50
+ "@fortawesome/ember-fontawesome": "^2.0.0",
51
+ "@fortawesome/fontawesome-svg-core": "6.4.0",
52
+ "@fortawesome/free-solid-svg-icons": "6.4.0",
53
+ "@fortawesome/free-brands-svg-icons": "6.4.0",
53
54
  "ember-cli-babel": "^8.2.0",
54
55
  "ember-cli-htmlbars": "^6.3.0",
55
56
  "ember-intl": "6.3.2",
@@ -69,7 +70,7 @@
69
70
  "broccoli-funnel": "^3.0.8",
70
71
  "broccoli-merge-trees": "^4.2.0",
71
72
  "concurrently": "^8.2.2",
72
- "ember-auto-import": "^2.6.3",
73
+ "ember-auto-import": "^2.7.4",
73
74
  "ember-classic-decorator": "^3.0.0",
74
75
  "ember-cli": "~5.4.1",
75
76
  "ember-cli-clean-css": "^3.0.0",
@@ -17,7 +17,7 @@ class Storefront
17
17
  /**
18
18
  * Guards these permissions should apply to.
19
19
  */
20
- public array $guards = ['web', 'api'];
20
+ public array $guards = ['sanctum'];
21
21
 
22
22
  /**
23
23
  * The permission schema resources.
@@ -25,11 +25,15 @@ class Storefront
25
25
  public array $resources = [
26
26
  [
27
27
  'name' => 'order',
28
- 'actions' => ['accept', 'mark-as-ready', 'mark-as-completed', 'reject'],
28
+ 'actions' => ['accept', 'mark-as-ready', 'mark-as-completed', 'reject', 'export', 'import'],
29
+ ],
30
+ [
31
+ 'name' => 'customer',
32
+ 'actions' => ['export'],
29
33
  ],
30
34
  [
31
35
  'name' => 'product',
32
- 'actions' => ['import'],
36
+ 'actions' => ['import', 'export'],
33
37
  ],
34
38
  [
35
39
  'name' => 'product-addon',
@@ -55,6 +59,10 @@ class Storefront
55
59
  'name' => 'product-variant-option',
56
60
  'actions' => [],
57
61
  ],
62
+ [
63
+ 'name' => 'product-category',
64
+ 'actions' => [],
65
+ ],
58
66
  [
59
67
  'name' => 'gateway',
60
68
  'actions' => [],
@@ -71,6 +79,10 @@ class Storefront
71
79
  'name' => 'network-store',
72
80
  'actions' => [],
73
81
  ],
82
+ [
83
+ 'name' => 'network-category',
84
+ 'actions' => [],
85
+ ],
74
86
  [
75
87
  'name' => 'store',
76
88
  'actions' => [],
@@ -83,5 +95,87 @@ class Storefront
83
95
  'name' => 'store-hour',
84
96
  'actions' => [],
85
97
  ],
98
+ [
99
+ 'name' => 'settings',
100
+ 'action' => ['import'],
101
+ 'remove_actions' => ['delete', 'export', 'list', 'create'],
102
+ ],
103
+ ];
104
+
105
+ /**
106
+ * Policies provided by this schema.
107
+ */
108
+ public array $policies = [
109
+ [
110
+ 'name' => 'InventoryManager',
111
+ 'description' => 'Policy for managing products and categories.',
112
+ 'permissions' => [
113
+ 'see extension',
114
+ '* product',
115
+ '* product-addon',
116
+ '* product-addon-category',
117
+ '* product-variant',
118
+ '* product-variant-option',
119
+ '* product-hour',
120
+ '* product-store-location',
121
+ '* product-category',
122
+ ],
123
+ ],
124
+ [
125
+ 'name' => 'OrderManager',
126
+ 'description' => 'Policy for managing order.',
127
+ 'permissions' => [
128
+ 'see extension',
129
+ '* order',
130
+ ],
131
+ ],
132
+ [
133
+ 'name' => 'CustomerService',
134
+ 'description' => 'Policy for providing support to customers.',
135
+ 'permissions' => [
136
+ 'see extension',
137
+ '* customer',
138
+ '* order',
139
+ ],
140
+ ],
141
+ [
142
+ 'name' => 'MarketplaceManager',
143
+ 'description' => 'Policy for managing networks.',
144
+ 'permissions' => [
145
+ 'see extension',
146
+ '* product',
147
+ '* order',
148
+ '* network',
149
+ '* network-store',
150
+ '* network-category',
151
+ ],
152
+ ],
153
+ ];
154
+
155
+ /**
156
+ * Roles provided by this schema.
157
+ */
158
+ public array $roles = [
159
+ [
160
+ 'name' => 'Storefront Administrator',
161
+ 'description' => 'Role for managing all of storefront resources.',
162
+ 'policies' => [
163
+ 'StorefrontFullAccess',
164
+ ],
165
+ ],
166
+ [
167
+ 'name' => 'Customer Service',
168
+ 'description' => 'Role for providing support to customers.',
169
+ 'policies' => [
170
+ 'CustomerService',
171
+ ],
172
+ ],
173
+ [
174
+ 'name' => 'Inventory Manager',
175
+ 'description' => 'Role for managing all products.',
176
+ 'policies' => [
177
+ 'InventoryManager',
178
+ ],
179
+ ],
86
180
  ];
87
181
  }
@@ -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
 
@@ -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');
@@ -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', []);
@@ -122,7 +122,7 @@ class Product extends FleetbaseResource
122
122
  });
123
123
  }
124
124
 
125
- public function mapProductAddons(\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
125
+ public function mapProductAddons(?\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
126
126
  {
127
127
  return collect($addons)->map(function ($addon) use ($excluded) {
128
128
  if (is_array($excluded) && in_array($addon->uuid, $excluded)) {
@@ -159,7 +159,7 @@ class Product extends FleetbaseResource
159
159
  })->filter()->values();
160
160
  }
161
161
 
162
- public function mapVariants(\Illuminate\Database\Eloquent\Collection $variants = null)
162
+ public function mapVariants(?\Illuminate\Database\Eloquent\Collection $variants = null)
163
163
  {
164
164
  return collect($variants)->map(function ($variant) {
165
165
  $productVariantArr = [
@@ -589,7 +589,7 @@ class Cart extends StorefrontModel
589
589
  *
590
590
  * @return \Fleetbase\Models\Storefront\Cart
591
591
  */
592
- public function updateCurrency(string $currencyCode = null, $save = false)
592
+ public function updateCurrency(?string $currencyCode = null, $save = false)
593
593
  {
594
594
  $this->attributes['currency'] = $currencyCode ?? session('storefront_currency');
595
595
 
@@ -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
 
@@ -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;