diff --git a/packages/Webkul/Shop/src/Http/Controllers/API/CategoryController.php b/packages/Webkul/Shop/src/Http/Controllers/API/CategoryController.php index 1c25b653bcc..b30d7fbbad9 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/API/CategoryController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/API/CategoryController.php @@ -7,6 +7,7 @@ use Webkul\Category\Repositories\CategoryRepository; use Webkul\Product\Repositories\ProductRepository; use Webkul\Shop\Http\Resources\AttributeResource; +use Webkul\Shop\Http\Resources\CategoryResource; class CategoryController extends APIController { @@ -23,6 +24,19 @@ public function __construct( ) { } + /** + * Get all categories. + */ + public function index(): JsonResource + { + $categories = $this->categoryRepository + ->whereNotNull('parent_id') + ->where('status', 1) + ->paginate(); + + return CategoryResource::collection($categories); + } + /** * Get filterable attributes for category. */ diff --git a/packages/Webkul/Shop/src/Http/Resources/CategoryResource.php b/packages/Webkul/Shop/src/Http/Resources/CategoryResource.php new file mode 100644 index 00000000000..030716c8b9c --- /dev/null +++ b/packages/Webkul/Shop/src/Http/Resources/CategoryResource.php @@ -0,0 +1,41 @@ + $this->id, + 'parent_id' => $this->parent_id, + 'name' => $this->name, + 'slug' => $this->slug, + 'url_path' => $this->url_path, + 'status' => $this->status, + 'position' => $this->position, + 'display_mode' => $this->display_mode, + 'description' => $this->description, + 'images' => [ + 'base_url' => $this->image_url, + 'banner_url' => $this->banner_url, + 'category_icon_url' => $this->category_icon_url, + ], + 'meta' => [ + 'title' => $this->meta_title, + 'keywords' => $this->meta_keywords, + 'description' => $this->meta_description, + ], + 'translations' => $this->translations, + 'additional' => $this->additional, + ]; + } +} diff --git a/packages/Webkul/Shop/src/Resources/views/components/categories/carousel.blade.php b/packages/Webkul/Shop/src/Resources/views/components/categories/carousel.blade.php new file mode 100644 index 00000000000..022e45a07a4 --- /dev/null +++ b/packages/Webkul/Shop/src/Resources/views/components/categories/carousel.blade.php @@ -0,0 +1,114 @@ + + + + +@pushOnce('scripts') + + + +@endPushOnce diff --git a/packages/Webkul/Shop/src/Resources/views/components/products/carousel.blade.php b/packages/Webkul/Shop/src/Resources/views/components/products/carousel.blade.php index e5b031cefd2..ab15e258672 100644 --- a/packages/Webkul/Shop/src/Resources/views/components/products/carousel.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/components/products/carousel.blade.php @@ -15,17 +15,22 @@
-
+
{ + this.$axios.get(this.src) + .then(response => { this.isLoading = false; this.products = response.data.data; @@ -81,6 +87,18 @@ class="block mx-auto text-navyBlue text-base w-max font-medium py-[11px] px-[43p console.log(error); }); }, + + swipeLeft() { + const container = this.$refs.swiperContainer; + + container.scrollLeft -= 720; + }, + + swipeRight() { + const container = this.$refs.swiperContainer; + + container.scrollLeft += 720; + }, }, }); diff --git a/packages/Webkul/Shop/src/Resources/views/components/shimmer/categories/carousel.blade.php b/packages/Webkul/Shop/src/Resources/views/components/shimmer/categories/carousel.blade.php new file mode 100644 index 00000000000..805d6633c92 --- /dev/null +++ b/packages/Webkul/Shop/src/Resources/views/components/shimmer/categories/carousel.blade.php @@ -0,0 +1,25 @@ +@props(['count' => 0]) + +
+
+
+ @for ($i = 0; $i < $count; $i++) +
+
+ +
+ +

+
+ @endfor +
+ + + + +
+
diff --git a/packages/Webkul/Shop/src/Resources/views/components/shimmer/products/cards/grid.blade.php b/packages/Webkul/Shop/src/Resources/views/components/shimmer/products/cards/grid.blade.php index c2bfc67dcf7..ea37872459f 100644 --- a/packages/Webkul/Shop/src/Resources/views/components/shimmer/products/cards/grid.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/components/shimmer/products/cards/grid.blade.php @@ -1,13 +1,17 @@ @props(['count' => 0]) @for ($i = 0; $i < $count; $i++) -
+
- +

+

diff --git a/packages/Webkul/Shop/src/Resources/views/components/shimmer/products/carousel.blade.php b/packages/Webkul/Shop/src/Resources/views/components/shimmer/products/carousel.blade.php index d34e39a2f4c..b473049bab5 100644 --- a/packages/Webkul/Shop/src/Resources/views/components/shimmer/products/carousel.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/components/shimmer/products/carousel.blade.php @@ -27,4 +27,4 @@ class="min-w-[291px]" @endif -
\ No newline at end of file +
diff --git a/packages/Webkul/Shop/src/Resources/views/home/index.blade.php b/packages/Webkul/Shop/src/Resources/views/home/index.blade.php index d6c817f73f5..5413260d1e5 100755 --- a/packages/Webkul/Shop/src/Resources/views/home/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/home/index.blade.php @@ -16,6 +16,14 @@ class="block text-[22px] py-[20px] font-medium text-center bg-[#E8EDFE] font-dms
+ {{-- Categories carousel --}} + + + {{-- Carousel --}} ['locale', 'theme', 'currency'], 'prefix' => 'api'], function () { Route::controller(ProductController::class)->group(function () { @@ -29,12 +29,12 @@ ->name('shop.api.products.reviews.store'); }); - Route::controller(CategoryController::class)->group(function () { - Route::get('categories/{id}/attributes', 'getAttributes') - ->name('shop.api.categories.attributes'); + Route::controller(CategoryController::class)->prefix('categories')->group(function () { + Route::get('', 'index')->name('shop.api.categories.index'); - Route::get('categories/{id}/max-price', 'getProductMaxPrice') - ->name('shop.api.categories.max_price'); + Route::get('{id}/attributes', 'getAttributes')->name('shop.api.categories.attributes'); + + Route::get('{id}/max-price', 'getProductMaxPrice')->name('shop.api.categories.max_price'); }); Route::controller(CartController::class)->prefix('checkout/cart')->group(function () { @@ -59,7 +59,7 @@ Route::post('move-to-wishlist', 'moveToWishlist')->name('shop.api.compare.move_to_wishlist'); }); - Route::group(['middleware' => ['customer']], function () { + Route::group(['middleware' => ['customer'], 'prefix' => 'customer'], function () { Route::controller(WishlistController::class)->prefix('wishlist')->group(function () { Route::get('', 'index')->name('shop.api.customers.account.wishlist.index'); @@ -70,9 +70,6 @@ Route::delete('{id}', 'destroy')->name('shop.api.customers.account.wishlist.destroy'); }); - Route::get('compare-items/{product_id}', [CompareController::class, 'store']) - ->name('shop.customers.account.compare.store'); - - Route::get('/customer/addresses', [AddressController::class,'index'])->name('api.shop.customers.account.addresses.index'); + Route::get('addresses', [AddressController::class, 'index'])->name('api.shop.customers.account.addresses.index'); }); });