@fleetbase/storefront-engine 0.1.6 → 0.1.8
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/.php-cs-fixer.php +29 -0
- package/LICENSE.md +16 -4
- package/README.md +106 -13
- package/addon/components/modals/add-store-to-category.hbs +5 -0
- package/addon/components/modals/create-network-category.hbs +28 -28
- package/addon/components/modals/share-network.hbs +3 -3
- package/addon/components/modals/store-details.hbs +22 -0
- package/addon/components/modals/store-form.hbs +22 -0
- package/addon/components/modals/store-form.js +21 -0
- package/addon/components/network-category-picker.hbs +40 -0
- package/addon/components/network-category-picker.js +83 -0
- package/addon/components/store-selector.hbs +4 -2
- package/addon/components/widget/orders.js +22 -17
- package/addon/controllers/networks/index/network/index.js +133 -9
- package/addon/controllers/networks/index/network/stores.js +422 -153
- package/addon/controllers/networks/index.js +66 -4
- package/addon/controllers/products/index/category.js +1 -1
- package/addon/controllers/settings/index.js +14 -7
- package/addon/controllers/settings/notifications.js +1 -1
- package/addon/models/store.js +44 -7
- package/addon/routes/networks/index/network/customers.js +4 -1
- package/addon/routes/networks/index/network/orders.js +4 -1
- package/addon/routes/networks/index/network/stores.js +19 -15
- package/addon/serializers/store.js +1 -0
- package/addon/templates/customers/index.hbs +0 -11
- package/addon/templates/networks/index/network/index.hbs +1 -1
- package/addon/templates/networks/index/network/stores.hbs +8 -163
- package/addon/templates/networks/index/network.hbs +2 -3
- package/addon/utils/create-shareable-link.js +21 -0
- package/app/adapters/addon-category.js +1 -1
- package/app/adapters/gateway.js +1 -1
- package/app/adapters/network.js +1 -1
- package/app/adapters/notification-channel.js +1 -1
- package/app/adapters/product-addon-category.js +1 -1
- package/app/adapters/product-addon.js +1 -1
- package/app/adapters/product-hour.js +1 -1
- package/app/adapters/product-store-location.js +1 -1
- package/app/adapters/product-variant-option.js +1 -1
- package/app/adapters/product-variant.js +1 -1
- package/app/adapters/product.js +1 -1
- package/app/adapters/store-hour.js +1 -1
- package/app/adapters/store-location.js +1 -1
- package/app/adapters/store.js +1 -1
- package/app/adapters/storefront.js +1 -1
- package/app/components/file-record.js +1 -1
- package/app/components/modals/add-store-hours.js +1 -1
- package/app/components/modals/add-store-to-category.js +1 -0
- package/app/components/modals/add-stores-to-network.js +1 -1
- package/app/components/modals/assign-driver.js +1 -1
- package/app/components/modals/create-first-store.js +1 -1
- package/app/components/modals/create-gateway.js +1 -1
- package/app/components/modals/create-network-category.js +1 -1
- package/app/components/modals/create-network.js +1 -1
- package/app/components/modals/create-new-variant.js +1 -1
- package/app/components/modals/create-notification-channel.js +1 -1
- package/app/components/modals/create-product-category.js +1 -1
- package/app/components/modals/create-store.js +1 -1
- package/app/components/modals/edit-network.js +1 -1
- package/app/components/modals/import-products.js +1 -1
- package/app/components/modals/incoming-order.js +1 -1
- package/app/components/modals/manage-addons.js +1 -1
- package/app/components/modals/order-ready-assign-driver.js +1 -1
- package/app/components/modals/select-addon-category.js +1 -1
- package/app/components/modals/share-network.js +1 -1
- package/app/components/modals/store-details.js +1 -0
- package/app/components/modals/store-form.js +1 -0
- package/app/components/modals/store-location-form.js +1 -1
- package/app/components/network-category-picker.js +1 -0
- package/app/components/order-card.js +1 -1
- package/app/components/schedule-manager.js +1 -1
- package/app/components/settings-container.js +1 -1
- package/app/components/store-selector.js +1 -1
- package/app/components/widget/customers.js +1 -1
- package/app/components/widget/orders.js +1 -1
- package/app/components/widget/storefront-metrics.js +1 -1
- package/app/controllers/application.js +1 -1
- package/app/controllers/customers/index.js +1 -1
- package/app/controllers/home.js +1 -1
- package/app/controllers/networks/index/network/customers.js +1 -1
- package/app/controllers/networks/index/network/index.js +1 -1
- package/app/controllers/networks/index/network/orders.js +1 -1
- package/app/controllers/networks/index/network/stores.js +1 -1
- package/app/controllers/networks/index/network.js +1 -1
- package/app/controllers/networks/index.js +1 -1
- package/app/controllers/orders/index.js +1 -1
- package/app/controllers/products/index/category/edit.js +1 -1
- package/app/controllers/products/index/category/new.js +1 -1
- package/app/controllers/products/index/category.js +1 -1
- package/app/controllers/products/index/index/edit.js +1 -1
- package/app/controllers/products/index/index.js +1 -1
- package/app/controllers/products/index.js +1 -1
- package/app/controllers/settings/api.js +1 -1
- package/app/controllers/settings/gateways.js +1 -1
- package/app/controllers/settings/index.js +1 -1
- package/app/controllers/settings/locations.js +1 -1
- package/app/controllers/settings/notifications.js +1 -1
- package/app/helpers/get-tip-amount.js +1 -1
- package/app/models/addon-category.js +1 -1
- package/app/models/gateway.js +1 -1
- package/app/models/network.js +1 -1
- package/app/models/notification-channel.js +1 -1
- package/app/models/product-addon-category.js +1 -1
- package/app/models/product-addon.js +1 -1
- package/app/models/product-hour.js +1 -1
- package/app/models/product-store-location.js +1 -1
- package/app/models/product-variant-option.js +1 -1
- package/app/models/product-variant.js +1 -1
- package/app/models/product.js +1 -1
- package/app/models/store-hour.js +1 -1
- package/app/models/store-location.js +1 -1
- package/app/models/store.js +1 -1
- package/app/routes/application.js +1 -1
- package/app/routes/customers/index/edit.js +1 -1
- package/app/routes/customers/index.js +1 -1
- package/app/routes/home.js +1 -1
- package/app/routes/networks/index/network/customers.js +1 -1
- package/app/routes/networks/index/network/index.js +1 -1
- package/app/routes/networks/index/network/orders.js +1 -1
- package/app/routes/networks/index/network/stores.js +1 -1
- package/app/routes/networks/index/network.js +1 -1
- package/app/routes/networks/index.js +1 -1
- package/app/routes/orders/index/edit.js +1 -1
- package/app/routes/orders/index/new.js +1 -1
- package/app/routes/orders/index/view.js +1 -1
- package/app/routes/orders/index.js +1 -1
- package/app/routes/products/index/category/edit.js +1 -1
- package/app/routes/products/index/category/new.js +1 -1
- package/app/routes/products/index/category.js +1 -1
- package/app/routes/products/index/index/edit.js +1 -1
- package/app/routes/products/index/index.js +1 -1
- package/app/routes/products/index.js +1 -1
- package/app/routes/settings/api.js +1 -1
- package/app/routes/settings/gateways.js +1 -1
- package/app/routes/settings/index.js +1 -1
- package/app/routes/settings/locations.js +1 -1
- package/app/routes/settings/notifications.js +1 -1
- package/app/serializers/addon-category.js +1 -1
- package/app/serializers/network.js +1 -1
- package/app/serializers/notification-channel.js +1 -1
- package/app/serializers/product-addon-category.js +1 -1
- package/app/serializers/product-variant.js +1 -1
- package/app/serializers/product.js +1 -1
- package/app/serializers/store-location.js +1 -1
- package/app/serializers/store.js +1 -1
- package/app/services/storefront.js +1 -1
- package/app/templates/customers/index/edit.js +1 -1
- package/app/templates/customers/index.js +1 -1
- package/app/templates/home.js +1 -1
- package/app/templates/networks/index/network/customers.js +1 -1
- package/app/templates/networks/index/network/index.js +1 -1
- package/app/templates/networks/index/network/orders.js +1 -1
- package/app/templates/networks/index/network/stores.js +1 -1
- package/app/templates/networks/index/network.js +1 -1
- package/app/templates/networks/index.js +1 -1
- package/app/templates/orders/index/edit.js +1 -1
- package/app/templates/orders/index/new.js +1 -1
- package/app/templates/orders/index/view.js +1 -1
- package/app/templates/orders/index.js +1 -1
- package/app/templates/products/index/category/edit.js +1 -1
- package/app/templates/products/index/category/new.js +1 -1
- package/app/templates/products/index/category.js +1 -1
- package/app/templates/products/index/index/edit.js +1 -1
- package/app/templates/products/index/index.js +1 -1
- package/app/templates/products/index.js +1 -1
- package/app/templates/settings/api.js +1 -1
- package/app/templates/settings/gateways.js +1 -1
- package/app/templates/settings/index.js +1 -1
- package/app/templates/settings/locations.js +1 -1
- package/app/templates/settings/notifications.js +1 -1
- package/app/templates/settings.js +1 -1
- package/app/utils/create-shareable-link.js +1 -0
- package/app/utils/get-gateway-schemas.js +1 -1
- package/app/utils/get-notification-schemas.js +1 -1
- package/composer.json +88 -0
- package/extension.json +10 -0
- package/package.json +6 -7
- package/phpstan.neon.dist +8 -0
- package/phpunit.xml.dist +16 -0
- package/server/.gitattributes +14 -0
- package/server/README.md +40 -0
- package/server/config/api.php +101 -0
- package/server/config/database.connections.php +57 -0
- package/server/config/storefront.php +19 -0
- package/server/config/twilio-notification-channel.php +36 -0
- package/server/migrations/2023_05_03_025307_create_carts_table.php +44 -0
- package/server/migrations/2023_05_03_025307_create_checkouts_table.php +51 -0
- package/server/migrations/2023_05_03_025307_create_gateways_table.php +48 -0
- package/server/migrations/2023_05_03_025307_create_network_stores_table.php +36 -0
- package/server/migrations/2023_05_03_025307_create_networks_table.php +56 -0
- package/server/migrations/2023_05_03_025307_create_notification_channels_table.php +43 -0
- package/server/migrations/2023_05_03_025307_create_payment_methods_table.php +44 -0
- package/server/migrations/2023_05_03_025307_create_product_addon_categories_table.php +38 -0
- package/server/migrations/2023_05_03_025307_create_product_addons_table.php +43 -0
- package/server/migrations/2023_05_03_025307_create_product_hours_table.php +37 -0
- package/server/migrations/2023_05_03_025307_create_product_store_locations_table.php +34 -0
- package/server/migrations/2023_05_03_025307_create_product_variant_options_table.php +40 -0
- package/server/migrations/2023_05_03_025307_create_product_variants_table.php +44 -0
- package/server/migrations/2023_05_03_025307_create_products_table.php +59 -0
- package/server/migrations/2023_05_03_025307_create_reviews_table.php +41 -0
- package/server/migrations/2023_05_03_025307_create_store_hours_table.php +37 -0
- package/server/migrations/2023_05_03_025307_create_store_locations_table.php +38 -0
- package/server/migrations/2023_05_03_025307_create_stores_table.php +57 -0
- package/server/migrations/2023_05_03_025307_create_votes_table.php +39 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_carts_table.php +40 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_checkouts_table.php +48 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_gateways_table.php +40 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_network_stores_table.php +40 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_networks_table.php +42 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_notification_channels_table.php +40 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_payment_methods_table.php +40 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_addon_categories_table.php +38 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_addons_table.php +38 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_hours_table.php +32 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_store_locations_table.php +34 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_variant_options_table.php +32 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_product_variants_table.php +32 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_products_table.php +44 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_reviews_table.php +38 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_store_hours_table.php +32 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_store_locations_table.php +40 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_stores_table.php +42 -0
- package/server/migrations/2023_05_03_025310_add_foreign_keys_to_votes_table.php +38 -0
- package/server/src/Auth/Schemas/Storefront.php +95 -0
- package/server/src/Console/Commands/NotifyStorefrontOrderNearby.php +86 -0
- package/server/src/Expansions/EntityExpansion.php +44 -0
- package/server/src/Http/Controllers/ActionController.php +119 -0
- package/server/src/Http/Controllers/AddonCategoryController.php +13 -0
- package/server/src/Http/Controllers/CustomerController.php +13 -0
- package/server/src/Http/Controllers/GatewayController.php +13 -0
- package/server/src/Http/Controllers/MetricsController.php +71 -0
- package/server/src/Http/Controllers/NetworkController.php +170 -0
- package/server/src/Http/Controllers/NotificationChannelController.php +13 -0
- package/server/src/Http/Controllers/OrderController.php +154 -0
- package/server/src/Http/Controllers/ProductAddonCategoryController.php +14 -0
- package/server/src/Http/Controllers/ProductAddonController.php +14 -0
- package/server/src/Http/Controllers/ProductController.php +123 -0
- package/server/src/Http/Controllers/ProductHourController.php +13 -0
- package/server/src/Http/Controllers/ProductVariantController.php +13 -0
- package/server/src/Http/Controllers/ProductVariantOptionController.php +13 -0
- package/server/src/Http/Controllers/ReviewController.php +13 -0
- package/server/src/Http/Controllers/StoreController.php +26 -0
- package/server/src/Http/Controllers/StoreHourController.php +13 -0
- package/server/src/Http/Controllers/StoreLocationController.php +13 -0
- package/server/src/Http/Controllers/StorefrontController.php +15 -0
- package/server/src/Http/Controllers/VoteController.php +13 -0
- package/server/src/Http/Controllers/v1/CartController.php +161 -0
- package/server/src/Http/Controllers/v1/CategoryController.php +138 -0
- package/server/src/Http/Controllers/v1/CheckoutController.php +957 -0
- package/server/src/Http/Controllers/v1/CustomerController.php +482 -0
- package/server/src/Http/Controllers/v1/GatewayControllerController.php +11 -0
- package/server/src/Http/Controllers/v1/NetworkController.php +281 -0
- package/server/src/Http/Controllers/v1/PaymentMethodController.php +11 -0
- package/server/src/Http/Controllers/v1/ProductController.php +94 -0
- package/server/src/Http/Controllers/v1/ReviewController.php +270 -0
- package/server/src/Http/Controllers/v1/ServiceQuoteController.php +402 -0
- package/server/src/Http/Controllers/v1/StoreController.php +176 -0
- package/server/src/Http/Filter/AddonCategoryFilter.php +19 -0
- package/server/src/Http/Filter/CustomerFilter.php +18 -0
- package/server/src/Http/Filter/GatewayFilter.php +13 -0
- package/server/src/Http/Filter/NetworkFilter.php +18 -0
- package/server/src/Http/Filter/NotificationChannelFilter.php +13 -0
- package/server/src/Http/Filter/OrderFilter.php +46 -0
- package/server/src/Http/Filter/ProductFilter.php +28 -0
- package/server/src/Http/Filter/StoreFilter.php +42 -0
- package/server/src/Http/Filter/StoreLocationFilter.php +23 -0
- package/server/src/Http/Middleware/SetStorefrontSession.php +130 -0
- package/server/src/Http/Requests/AddStoreToNetworkCategory.php +45 -0
- package/server/src/Http/Requests/CaptureOrderRequest.php +30 -0
- package/server/src/Http/Requests/CreateCustomerRequest.php +44 -0
- package/server/src/Http/Requests/CreateReviewRequest.php +34 -0
- package/server/src/Http/Requests/GetServiceQuoteFromCart.php +40 -0
- package/server/src/Http/Requests/InitializeCheckoutRequest.php +38 -0
- package/server/src/Http/Requests/NetworkActionRequest.php +43 -0
- package/server/src/Http/Requests/VerifyCreateCustomerRequest.php +31 -0
- package/server/src/Http/Resources/Cart.php +31 -0
- package/server/src/Http/Resources/Category.php +48 -0
- package/server/src/Http/Resources/Customer.php +36 -0
- package/server/src/Http/Resources/Gateway.php +32 -0
- package/server/src/Http/Resources/Media.php +29 -0
- package/server/src/Http/Resources/Network.php +48 -0
- package/server/src/Http/Resources/Product.php +209 -0
- package/server/src/Http/Resources/Review.php +45 -0
- package/server/src/Http/Resources/ReviewCustomer.php +60 -0
- package/server/src/Http/Resources/Store.php +76 -0
- package/server/src/Http/Resources/StoreHour.php +29 -0
- package/server/src/Http/Resources/StoreLocation.php +33 -0
- package/server/src/Imports/ProductsImport.php +20 -0
- package/server/src/Jobs/DownloadProductImageUrl.php +60 -0
- package/server/src/Listeners/HandleOrderCompleted.php +31 -0
- package/server/src/Listeners/HandleOrderDispatched.php +34 -0
- package/server/src/Listeners/HandleOrderDriverAssigned.php +37 -0
- package/server/src/Listeners/HandleOrderStarted.php +27 -0
- package/server/src/Mail/StorefrontNetworkInvite.php +48 -0
- package/server/src/Models/AddonCategory.php +30 -0
- package/server/src/Models/Cart.php +691 -0
- package/server/src/Models/Checkout.php +166 -0
- package/server/src/Models/Customer.php +88 -0
- package/server/src/Models/Gateway.php +165 -0
- package/server/src/Models/Network.php +300 -0
- package/server/src/Models/NetworkStore.php +86 -0
- package/server/src/Models/NotificationChannel.php +147 -0
- package/server/src/Models/PaymentMethod.php +99 -0
- package/server/src/Models/Product.php +315 -0
- package/server/src/Models/ProductAddon.php +128 -0
- package/server/src/Models/ProductAddonCategory.php +90 -0
- package/server/src/Models/ProductHour.php +59 -0
- package/server/src/Models/ProductStoreLocation.php +77 -0
- package/server/src/Models/ProductVariant.php +125 -0
- package/server/src/Models/ProductVariantOption.php +86 -0
- package/server/src/Models/Review.php +127 -0
- package/server/src/Models/Store.php +478 -0
- package/server/src/Models/StoreHour.php +59 -0
- package/server/src/Models/StoreLocation.php +126 -0
- package/server/src/Models/StorefrontModel.php +22 -0
- package/server/src/Models/Vote.php +84 -0
- package/server/src/Notifications/StorefrontOrderCanceled.php +196 -0
- package/server/src/Notifications/StorefrontOrderCompleted.php +201 -0
- package/server/src/Notifications/StorefrontOrderCreated.php +157 -0
- package/server/src/Notifications/StorefrontOrderDriverAssigned.php +200 -0
- package/server/src/Notifications/StorefrontOrderEnroute.php +199 -0
- package/server/src/Notifications/StorefrontOrderNearby.php +201 -0
- package/server/src/Notifications/StorefrontOrderPreparing.php +202 -0
- package/server/src/Notifications/StorefrontOrderReadyForPickup.php +202 -0
- package/server/src/Observers/NetworkObserver.php +40 -0
- package/server/src/Observers/ProductObserver.php +118 -0
- package/server/src/Providers/EventServiceProvider.php +23 -0
- package/server/src/Providers/StorefrontServiceProvider.php +103 -0
- package/server/src/Support/Metrics.php +193 -0
- package/server/src/Support/OrderConfig.php +13 -0
- package/server/src/Support/QPay.php +208 -0
- package/server/src/Support/Storefront.php +201 -0
- package/server/src/routes.php +180 -0
- package/server/tests/Feature.php +5 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
use Illuminate\Support\Str;
|
|
8
|
+
|
|
9
|
+
class Customer extends FleetbaseResource
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Transform the resource into an array.
|
|
13
|
+
*
|
|
14
|
+
* @param \Illuminate\Http\Request $request
|
|
15
|
+
* @return array
|
|
16
|
+
*/
|
|
17
|
+
public function toArray($request)
|
|
18
|
+
{
|
|
19
|
+
return [
|
|
20
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, Str::replaceFirst('contact', 'customer', $this->public_id)),
|
|
21
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
22
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
23
|
+
'internal_id' => $this->internal_id,
|
|
24
|
+
'name' => $this->name,
|
|
25
|
+
'photo_url' => $this->photo_url,
|
|
26
|
+
'email' => $this->email,
|
|
27
|
+
'phone' => $this->phone,
|
|
28
|
+
'address' => data_get($this, 'address.address'),
|
|
29
|
+
'addresses' => $this->addresses,
|
|
30
|
+
'token' => $this->when($this->token, $this->token),
|
|
31
|
+
'slug' => $this->slug,
|
|
32
|
+
'created_at' => $this->created_at,
|
|
33
|
+
'updated_at' => $this->updated_at,
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -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 Gateway extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
* @return array
|
|
15
|
+
*/
|
|
16
|
+
public function toArray($request)
|
|
17
|
+
{
|
|
18
|
+
return [
|
|
19
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id,$this->public_id),
|
|
20
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
21
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
22
|
+
'name' => $this->name,
|
|
23
|
+
'description' => $this->description,
|
|
24
|
+
'logo_url' => $this->logo_url,
|
|
25
|
+
'code' => $this->code,
|
|
26
|
+
'type' => $this->type,
|
|
27
|
+
'sandbox' => $this->sandbox,
|
|
28
|
+
'return_url' => $this->return_url,
|
|
29
|
+
'callback_url' => $this->callback_url,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class Media extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
* @return array
|
|
15
|
+
*/
|
|
16
|
+
public function toArray($request)
|
|
17
|
+
{
|
|
18
|
+
return [
|
|
19
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
20
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
21
|
+
'filename' => data_get($this, 'original_filename'),
|
|
22
|
+
'type' => data_get($this, 'content_type'),
|
|
23
|
+
'caption' => data_get($this, 'caption'),
|
|
24
|
+
'url' => data_get($this, 'url'),
|
|
25
|
+
'created_at' => $this->when(Http::isInternalRequest(), $this->created_at),
|
|
26
|
+
'updated_at' => $this->when(Http::isInternalRequest(), $this->updated_at),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class Network extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
* @return array
|
|
15
|
+
*/
|
|
16
|
+
public function toArray($request)
|
|
17
|
+
{
|
|
18
|
+
return [
|
|
19
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id,$this->public_id),
|
|
20
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
21
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
22
|
+
'key' => $this->when(Http::isInternalRequest(), $this->key),
|
|
23
|
+
'name' => $this->name,
|
|
24
|
+
'description' => $this->description,
|
|
25
|
+
'translations' => $this->translations ?? [],
|
|
26
|
+
'website' => $this->website,
|
|
27
|
+
'facebook' => $this->facebook,
|
|
28
|
+
'instagram' => $this->instagram,
|
|
29
|
+
'twitter' => $this->twitter,
|
|
30
|
+
'email' => $this->email,
|
|
31
|
+
'phone' => $this->phone,
|
|
32
|
+
'tags' => $this->tags ?? [],
|
|
33
|
+
'currency' => $this->currency ?? 'USD',
|
|
34
|
+
'options' => $this->options ?? [],
|
|
35
|
+
'logo_url' => $this->logo_url,
|
|
36
|
+
'backdrop_url' => $this->backdrop_url,
|
|
37
|
+
'rating' => $this->rating,
|
|
38
|
+
'online' => $this->online,
|
|
39
|
+
'stores' => $this->when($request->boolean('with_stores') || $request->inArray('with', 'stores'), Store::collection($this->stores)),
|
|
40
|
+
'categories' => $this->when($request->boolean('with_categories') || $request->inArray('with', 'categories'), Category::collection($this->categories)),
|
|
41
|
+
'is_network' => true,
|
|
42
|
+
'is_store' => false,
|
|
43
|
+
'slug' => $this->slug,
|
|
44
|
+
'created_at' => $this->created_at,
|
|
45
|
+
'updated_at' => $this->updated_at,
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
use Illuminate\Support\Arr;
|
|
8
|
+
use Illuminate\Support\Str;
|
|
9
|
+
|
|
10
|
+
class Product extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Transform the resource into an array.
|
|
14
|
+
*
|
|
15
|
+
* @param \Illuminate\Http\Request $request
|
|
16
|
+
* @return array
|
|
17
|
+
*/
|
|
18
|
+
public function toArray($request)
|
|
19
|
+
{
|
|
20
|
+
return [
|
|
21
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
22
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
23
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
24
|
+
'name' => $this->name,
|
|
25
|
+
'description' => $this->description,
|
|
26
|
+
'sku' => $this->sku,
|
|
27
|
+
'primary_image_url' => $this->primary_image_url,
|
|
28
|
+
'price' => $this->price,
|
|
29
|
+
'sale_price' => $this->sale_price,
|
|
30
|
+
'currency' => $this->currency,
|
|
31
|
+
'is_on_sale' => $this->is_on_sale,
|
|
32
|
+
'is_recommended' => $this->is_recommended,
|
|
33
|
+
'is_service' => $this->is_service,
|
|
34
|
+
'is_bookable' => $this->is_bookable,
|
|
35
|
+
'is_available' => $this->is_available,
|
|
36
|
+
'tags' => $this->tags ?? [],
|
|
37
|
+
'status' => $this->status,
|
|
38
|
+
'slug' => $this->slug,
|
|
39
|
+
'translations' => $this->translations ?? [],
|
|
40
|
+
'addon_categories' => $this->mapAddonCategories($this->addonCategories),
|
|
41
|
+
'variants' => $this->mapVariants($this->variants),
|
|
42
|
+
'files' => $this->when(Http::isInternalRequest(), $this->files),
|
|
43
|
+
'images' => $this->when(!Http::isInternalRequest(), $this->mapFiles($this->files)),
|
|
44
|
+
'videos' => $this->when(!Http::isInternalRequest(), $this->mapFiles($this->files, 'video')),
|
|
45
|
+
'hours' => $this->mapHours($this->hours),
|
|
46
|
+
'youtube_urls' => $this->youtube_urls ?? [],
|
|
47
|
+
'created_at' => $this->created_at,
|
|
48
|
+
'updated_at' => $this->updated_at,
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public function mapHours(?\Illuminate\Database\Eloquent\Collection $hours = null): array
|
|
53
|
+
{
|
|
54
|
+
if (empty($hours)) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return array_map(
|
|
59
|
+
function ($hour) {
|
|
60
|
+
// modify for internal requests
|
|
61
|
+
if (Http::isInternalRequest()) {
|
|
62
|
+
$hour['id'] = data_get($hour, 'id');
|
|
63
|
+
$hour['uuid'] = data_get($hour, 'uuid');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return array_merge($hour, [
|
|
67
|
+
'day' => data_get($hour, 'day_of_week'),
|
|
68
|
+
'start' => data_get($hour, 'start'),
|
|
69
|
+
'end' => data_get($hour, 'end'),
|
|
70
|
+
]);
|
|
71
|
+
},
|
|
72
|
+
$hours->toArray()
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public function mapFiles(?\Illuminate\Database\Eloquent\Collection $files = null, $contentType = 'image')
|
|
77
|
+
{
|
|
78
|
+
return collect($files)->map(function ($file) use ($contentType) {
|
|
79
|
+
if (!Str::contains($file->content_type, $contentType)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return $file->url;
|
|
84
|
+
})->filter()->values();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public function mapAddonCategories(?\Illuminate\Database\Eloquent\Collection $addonCategories = null)
|
|
88
|
+
{
|
|
89
|
+
return collect($addonCategories)->map(function ($addonCategory) {
|
|
90
|
+
$addonCategoryArr = [
|
|
91
|
+
'id' => $addonCategory->category->public_id ?? null,
|
|
92
|
+
'name' => $addonCategory->name,
|
|
93
|
+
'description' => $addonCategory->category->description ?? null,
|
|
94
|
+
'addons' => $this->mapProductAddons($addonCategory->category->addons ?? [], $addonCategory->excluded_addons)
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
// modify for internal requests
|
|
98
|
+
if (Http::isInternalRequest()) {
|
|
99
|
+
$addonCategoryArr['id'] = $addonCategory->category->id;
|
|
100
|
+
|
|
101
|
+
$addonCategoryArr = Arr::insertAfterKey(
|
|
102
|
+
$addonCategoryArr,
|
|
103
|
+
[
|
|
104
|
+
'uuid' => $addonCategory->category->uuid,
|
|
105
|
+
'public_id' => $addonCategory->category->public_id
|
|
106
|
+
],
|
|
107
|
+
'id'
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return $addonCategoryArr;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public function mapProductAddons(?\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
|
|
116
|
+
{
|
|
117
|
+
return collect($addons)->map(function ($addon) use ($excluded) {
|
|
118
|
+
if (is_array($excluded) && in_array($addon->uuid, $excluded)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
$productAddonArr = [
|
|
123
|
+
'id' => $addon->public_id,
|
|
124
|
+
'name' => $addon->name,
|
|
125
|
+
'description' => $addon->description,
|
|
126
|
+
'price' => $addon->price,
|
|
127
|
+
'sale_price' => $addon->sale_price,
|
|
128
|
+
'is_on_sale' => $addon->is_on_sale,
|
|
129
|
+
'slug' => $addon->slug,
|
|
130
|
+
'created_at' => $addon->created_at,
|
|
131
|
+
'updated_at' => $addon->updated_at
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
// modify for internal requests
|
|
135
|
+
if (Http::isInternalRequest()) {
|
|
136
|
+
$productAddonArr['id'] = $addon->id;
|
|
137
|
+
|
|
138
|
+
$productAddonArr = Arr::insertAfterKey(
|
|
139
|
+
$productAddonArr,
|
|
140
|
+
[
|
|
141
|
+
'uuid' => $addon->uuid,
|
|
142
|
+
'public_id' => $addon->public_id
|
|
143
|
+
],
|
|
144
|
+
'id'
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return $productAddonArr;
|
|
149
|
+
})->filter()->values();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public function mapVariants(?\Illuminate\Database\Eloquent\Collection $variants = null)
|
|
153
|
+
{
|
|
154
|
+
return collect($variants)->map(function ($variant) {
|
|
155
|
+
$productVariantArr = [
|
|
156
|
+
'id' => $variant->public_id,
|
|
157
|
+
'name' => $variant->name,
|
|
158
|
+
'description' => $variant->description,
|
|
159
|
+
'is_multiselect' => $variant->is_multiselect,
|
|
160
|
+
'is_required' => $variant->is_required,
|
|
161
|
+
'slug' => $variant->slug,
|
|
162
|
+
'options' => collect($variant->options)->map(function ($variantOpt) {
|
|
163
|
+
$variantOptArr = [
|
|
164
|
+
'id' => $variantOpt->public_id,
|
|
165
|
+
'name' => $variantOpt->name,
|
|
166
|
+
'description' => $variantOpt->description,
|
|
167
|
+
'additional_cost' => $variantOpt->additional_cost,
|
|
168
|
+
'created_at' => $variantOpt->created_at,
|
|
169
|
+
'updated_at' => $variantOpt->updated_at
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
// modify for internal requests
|
|
173
|
+
if (Http::isInternalRequest()) {
|
|
174
|
+
$variantOptArr['id'] = $variantOpt->id;
|
|
175
|
+
|
|
176
|
+
$variantOptArr = Arr::insertAfterKey(
|
|
177
|
+
$variantOptArr,
|
|
178
|
+
[
|
|
179
|
+
'uuid' => $variantOpt->uuid,
|
|
180
|
+
'public_id' => $variantOpt->public_id
|
|
181
|
+
],
|
|
182
|
+
'id'
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return $variantOptArr;
|
|
187
|
+
}),
|
|
188
|
+
'created_at' => $variant->created_at,
|
|
189
|
+
'updated_at' => $variant->updated_at
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
// modify for internal requests
|
|
193
|
+
if (Http::isInternalRequest()) {
|
|
194
|
+
$productVariantArr['id'] = $variant->id;
|
|
195
|
+
|
|
196
|
+
$productVariantArr = Arr::insertAfterKey(
|
|
197
|
+
$productVariantArr,
|
|
198
|
+
[
|
|
199
|
+
'uuid' => $variant->uuid,
|
|
200
|
+
'public_id' => $variant->public_id
|
|
201
|
+
],
|
|
202
|
+
'id'
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return $productVariantArr;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class Review extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
* @return array
|
|
15
|
+
*/
|
|
16
|
+
public function toArray($request)
|
|
17
|
+
{
|
|
18
|
+
return [
|
|
19
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
20
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
21
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
22
|
+
'subject_id' => $this->subject->id,
|
|
23
|
+
'rating' => $this->rating,
|
|
24
|
+
'content' => $this->content,
|
|
25
|
+
'customer' => new ReviewCustomer($this->customer),
|
|
26
|
+
'slug' => $this->slug,
|
|
27
|
+
'photos' => $this->mapPhotos($this->photos),
|
|
28
|
+
'created_at' => $this->created_at,
|
|
29
|
+
'updated_at' => $this->updated_at,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public function mapPhotos($photos = [])
|
|
34
|
+
{
|
|
35
|
+
return collect($photos)->map(function ($photo) {
|
|
36
|
+
return [
|
|
37
|
+
'id' => $photo->public_id,
|
|
38
|
+
'filename' => $photo->original_filename,
|
|
39
|
+
'type' => $photo->content_type,
|
|
40
|
+
'caption' => $photo->caption,
|
|
41
|
+
'url' => $photo->url
|
|
42
|
+
];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
use Illuminate\Support\Str;
|
|
8
|
+
|
|
9
|
+
class ReviewCustomer extends FleetbaseResource
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Transform the resource into an array.
|
|
13
|
+
*
|
|
14
|
+
* @param \Illuminate\Http\Request $request
|
|
15
|
+
* @return array
|
|
16
|
+
*/
|
|
17
|
+
public function toArray($request)
|
|
18
|
+
{
|
|
19
|
+
return [
|
|
20
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, Str::replaceFirst('contact', 'customer', $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
|
+
'email' => $this->email,
|
|
25
|
+
'phone' => $this->phone,
|
|
26
|
+
'photo_url' => $this->photo_url,
|
|
27
|
+
'reviews_count' => $this->getReviewsCount(),
|
|
28
|
+
'uploads_count' => $this->getUploadsCount(),
|
|
29
|
+
'slug' => $this->slug,
|
|
30
|
+
'created_at' => $this->created_at,
|
|
31
|
+
'updated_at' => $this->updated_at,
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public function getReviewsCount()
|
|
36
|
+
{
|
|
37
|
+
if (session('storefront_network')) {
|
|
38
|
+
return $this->storeReviews()->whereHas('subject', function ($q) {
|
|
39
|
+
$q->whereHas('networks', function ($q) {
|
|
40
|
+
$q->where('network_uuid', session('storefront_network'));
|
|
41
|
+
});
|
|
42
|
+
})->count();
|
|
43
|
+
|
|
44
|
+
// $productReviewsCount = $this->productReviews()->whereHas('subject', function ($q) {
|
|
45
|
+
// $q->whereHas('store', function ($q) {
|
|
46
|
+
// $q->whereHas('networks', function ($q) {
|
|
47
|
+
// $q->where('network_uuid', session('storefront_network'));
|
|
48
|
+
// });
|
|
49
|
+
// });
|
|
50
|
+
// })->count();
|
|
51
|
+
|
|
52
|
+
// return $storeReviewsCount + $productReviewsCount;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public function getUploadsCount()
|
|
57
|
+
{
|
|
58
|
+
return $this->reviewUploads()->count();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class Store extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
* @return array
|
|
15
|
+
*/
|
|
16
|
+
public function toArray($request)
|
|
17
|
+
{
|
|
18
|
+
return [
|
|
19
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
20
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
21
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
22
|
+
'key' => $this->when(Http::isInternalRequest(), $this->key),
|
|
23
|
+
'name' => $this->name,
|
|
24
|
+
'description' => $this->description,
|
|
25
|
+
'translations' => $this->translations ?? [],
|
|
26
|
+
'website' => $this->website,
|
|
27
|
+
'facebook' => $this->facebook,
|
|
28
|
+
'instagram' => $this->instagram,
|
|
29
|
+
'twitter' => $this->twitter,
|
|
30
|
+
'email' => $this->email,
|
|
31
|
+
'phone' => $this->phone,
|
|
32
|
+
'tags' => $this->tags ?? [],
|
|
33
|
+
'currency' => $this->currency ?? 'USD',
|
|
34
|
+
'options' => $this->formatOptions($this->options),
|
|
35
|
+
'logo_url' => $this->logo_url,
|
|
36
|
+
'backdrop_url' => $this->backdrop_url,
|
|
37
|
+
'rating' => $this->rating,
|
|
38
|
+
'online' => $this->online,
|
|
39
|
+
'is_network' => false,
|
|
40
|
+
'is_store' => true,
|
|
41
|
+
'category' => $this->when($request->filled('network') && $request->has('with_category'), new Category($this->getNetworkCategoryUsingId($request->input('network')))),
|
|
42
|
+
'networks' => $this->when($request->boolean('with_networks') || $request->inArray('with', 'networks'), Network::collection($this->networks)),
|
|
43
|
+
'locations' => $this->when($request->boolean('with_locations'), $this->locations->mapInto(StoreLocation::class)),
|
|
44
|
+
'media' => $this->when($request->boolean('with_media'), Media::collection($this->media)),
|
|
45
|
+
'slug' => $this->slug,
|
|
46
|
+
'created_at' => $this->created_at,
|
|
47
|
+
'updated_at' => $this->updated_at,
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Format the given options array by removing excluded keys.
|
|
53
|
+
*
|
|
54
|
+
* @param mixed $options The options array to format.
|
|
55
|
+
* @return array The formatted options array.
|
|
56
|
+
*/
|
|
57
|
+
public function formatOptions($options = []): array
|
|
58
|
+
{
|
|
59
|
+
if (!is_array($options)) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
$formattedOptions = [];
|
|
64
|
+
$exclude = ['alerted_for_new_order'];
|
|
65
|
+
|
|
66
|
+
foreach ($options as $key => $value) {
|
|
67
|
+
if (in_array($key, $exclude)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
$formattedOptions[$key] = $value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return $formattedOptions;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
|
|
8
|
+
class StoreHour extends FleetbaseResource
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Transform the resource into an array.
|
|
12
|
+
*
|
|
13
|
+
* @param \Illuminate\Http\Request $request
|
|
14
|
+
* @return array
|
|
15
|
+
*/
|
|
16
|
+
public function toArray($request)
|
|
17
|
+
{
|
|
18
|
+
return [
|
|
19
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
20
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
21
|
+
'day_of_week' => $this->when(Http::isInternalRequest(), $this->day_of_week),
|
|
22
|
+
'day' => $this->day_of_week,
|
|
23
|
+
'start' => $this->start,
|
|
24
|
+
'end' => $this->end,
|
|
25
|
+
'created_at' => $this->when(Http::isInternalRequest(), $this->created_at),
|
|
26
|
+
'updated_at' => $this->when(Http::isInternalRequest(), $this->updated_at),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Resources;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Http\Resources\v1\Place;
|
|
6
|
+
use Fleetbase\FleetOps\Http\Resources\Internal\v1\Place as InternalPlace;
|
|
7
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
8
|
+
use Fleetbase\Support\Http;
|
|
9
|
+
|
|
10
|
+
class StoreLocation extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Transform the resource into an array.
|
|
14
|
+
*
|
|
15
|
+
* @param \Illuminate\Http\Request $request
|
|
16
|
+
* @return array
|
|
17
|
+
*/
|
|
18
|
+
public function toArray($request)
|
|
19
|
+
{
|
|
20
|
+
return [
|
|
21
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
22
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
23
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
24
|
+
'store' => data_get($this, 'store.public_id'),
|
|
25
|
+
'store_data' => $this->when($request->boolean('with_store'), new Store($this->store)),
|
|
26
|
+
'name' => $this->name,
|
|
27
|
+
'place' => $this->when(Http::isInternalRequest(), new InternalPlace($this->place), new Place($this->place)),
|
|
28
|
+
'hours' => StoreHour::collection($this->hours),
|
|
29
|
+
'created_at' => $this->created_at,
|
|
30
|
+
'updated_at' => $this->updated_at,
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Imports;
|
|
4
|
+
|
|
5
|
+
use Illuminate\Support\Collection;
|
|
6
|
+
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
7
|
+
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
8
|
+
|
|
9
|
+
class ProductsImport implements ToCollection, WithHeadingRow
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* @param array $row
|
|
13
|
+
*
|
|
14
|
+
* @return \Illuminate\Support\Collection
|
|
15
|
+
*/
|
|
16
|
+
public function collection(Collection $rows)
|
|
17
|
+
{
|
|
18
|
+
return $rows;
|
|
19
|
+
}
|
|
20
|
+
}
|