diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index d1f3ff0..ccb4a40 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\Category; +use App\Models\Product; use Illuminate\Http\Request; class CollectionController extends Controller @@ -12,10 +13,13 @@ public function index() { } public function products(Category $category) { - return view('frontend.products.index'); + $products = $category->products()->get(); + return view('frontend.products.index',compact('category', 'products')); } - public function show(Category $category) { - return view('frontend.products.show'); + public function show(Category $category, Product $product) { + $product = $category->products()->where('slug', $product->slug)->first(); + $alsoPurchased = Product::where('slug', '!=', $product->slug)->take(4)->get(); + return view('frontend.products.show', compact('product', 'alsoPurchased')); } } diff --git a/app/Http/Controllers/HomePageController.php b/app/Http/Controllers/HomePageController.php index b6cbde1..35fd029 100644 --- a/app/Http/Controllers/HomePageController.php +++ b/app/Http/Controllers/HomePageController.php @@ -2,11 +2,13 @@ namespace App\Http\Controllers; +use App\Models\Product; use Illuminate\Http\Request; class HomePageController extends Controller { public function index() { - return view('frontend.home'); + $products = Product::where('featured', '=', '1')->inRandomOrder()->take(4)->get(); + return view('frontend.home', compact('products')); } } diff --git a/resources/views/components/frontend/footer.blade.php b/resources/views/components/frontend/footer.blade.php index 588824d..1c702bf 100644 --- a/resources/views/components/frontend/footer.blade.php +++ b/resources/views/components/frontend/footer.blade.php @@ -12,14 +12,14 @@

Products

diff --git a/resources/views/components/frontend/nav.blade.php b/resources/views/components/frontend/nav.blade.php index f6b05f1..8daca4f 100644 --- a/resources/views/components/frontend/nav.blade.php +++ b/resources/views/components/frontend/nav.blade.php @@ -31,7 +31,7 @@
Hats and sweaters on wood shelves next to various colors of t-shirts on hangers.
- + New Arrivals @@ -39,9 +39,9 @@
- Model wearing light heather gray t-shirt. + Model putting folded cash into slim card holder olive leather wallet with hand stitching.
- + Clothing @@ -51,7 +51,7 @@
Model putting folded cash into slim card holder olive leather wallet with hand stitching.
- + Shoes @@ -61,7 +61,7 @@
Grey 6-panel baseball hat with black brim, black mountain graphic on front, and light heather gray body.
- + Accessories @@ -77,10 +77,15 @@
About
+
Contact
+
+ Help +
+
@@ -106,7 +111,7 @@
@@ -203,7 +209,7 @@
- + Your Company diff --git a/resources/views/frontend/collections/index.blade.php b/resources/views/frontend/collections/index.blade.php index 603be3f..6f59995 100644 --- a/resources/views/frontend/collections/index.blade.php +++ b/resources/views/frontend/collections/index.blade.php @@ -6,8 +6,10 @@
@@ -67,7 +67,7 @@ class="h-full w-full object-cover object-center">

Shop by Category

- @@ -78,7 +78,7 @@ class="h-full w-full object-cover object-center">
- New Arrivals - Clothing - Shoes - Accessories -
- +
+

Featured Products

+ +
-
-
-
- Hand stitched, orange leather long wallet. -
-

- - - Basic tee - -

-

$75

-
-
-
- 12-sided, machined black pencil and pen. -
-

- - - Plain tee - -

-

$70

-
-
-
- Set of three light and dark brown mini sketch books. -
-

- - - Drop shoulder tee - -

-

$27

-
-
-
- Beautiful walnut organizer set with multiple white compartments +
+ @foreach( $products as $product ) +
+
+ Product image +
+

+ + + {{ $product->name }} + +

+

${{ $product->price }}

-

- - - Fit tee - -

-

$149

-
- -
+ @endforeach +
- +
-
+
@@ -246,7 +211,7 @@ class="h-full w-full object-cover object-center"> Up to 50% off.
- + Shop the sale diff --git a/resources/views/frontend/products/index.blade.php b/resources/views/frontend/products/index.blade.php index 84faa2b..d08dddc 100644 --- a/resources/views/frontend/products/index.blade.php +++ b/resources/views/frontend/products/index.blade.php @@ -1,7 +1,7 @@
-

Workspace

-

The secret to a tidy desk? Don't get rid of anything, just put it in really really nice looking containers.

+

{{ $category->name }}

+

{!! $category->description !!}

@@ -155,114 +155,26 @@

Products

+ @foreach( $products as $product )
- Eight shirts arranged on table in black, olive, grey, blue, white, red, mustard, and green. + Eight shirts arranged on table in black, olive, grey, blue, white, red, mustard, and green.

- + - Basic Tee 8-Pack + {{ $product->name }}

-

Get the full lineup of our Basic Tees. Have a fresh shirt all week, and an extra for laundry day.

+

{!! $product->description !!}

-

8 colors

-

$256

-
-
-
-
-
- Front of plain black t-shirt. -
-
-

- - - Basic Tee - -

-

Look like a visionary CEO and wear the same black t-shirt every day.

-
-

Black

-

$32

-
-
-
-
-
- Front of plain white t-shirt. -
-
-

- - - Kinda White Basic Tee - -

-

It's probably, like, 5000 Kelvin instead of 6000 K.

-
-

White

-

$32

-
-
-
-
-
- Front of plain dark gray t-shirt. -
-
-

- - - Stone Basic Tee - -

-

White tees stain easily, and black tees fade. This is going to be gray for a while.

-
-

Charcoal

-

$32

-
-
-
-
-
- Three shirts arranged on table in mustard, dark gray, and olive. -
-
-

- - - Fall Basic Tee 3-Pack - -

-

Who need stark minimalism when you could have earth tones? Embrace the season.

-
-

Charcoal

-

$96

-
-
-
-
-
- Three shirts in gray, white, and blue arranged on table with same line drawing of hands and shapes overlapping on front of shirt. -
-
-

- - - Linework Artwork Tee 3-Pack - -

-

Get all 3 colors of our popular Linework design and some variety to your monotonous life.

-
-

3 colors

-

$108

+ +

${{ $product->price }}

+ @endforeach
diff --git a/resources/views/frontend/products/show.blade.php b/resources/views/frontend/products/show.blade.php index f3c0d36..c0521a7 100644 --- a/resources/views/frontend/products/show.blade.php +++ b/resources/views/frontend/products/show.blade.php @@ -4,7 +4,7 @@
  1. - Men + Home @@ -12,7 +12,15 @@
  2. - Clothing + Collections + +
    +
  3. +
  4. +
    + {{ $product->category->name }} @@ -20,7 +28,7 @@
  5. - Basic Tee 6-Pack + {{ $product->name }}
@@ -28,31 +36,31 @@
- Model wearing plain white basic tee. + Model wearing plain white basic tee.
-

Basic Tee 6-Pack

+

{{ $product->name }}

Product information

-

$192

+

${{ $product->price }}

@@ -177,7 +185,7 @@

Description

-

The Basic Tee 6-Pack allows you to fully express your vibrant personality with three grayscale options. Feeling adventurous? Put on a heather gray tee. Want to be a trendsetter? Try our exclusive colorway: "Black". Need to add an extra pop of color to your outfit? Our white tee has you covered.

+

{!! $product->description !!}

@@ -210,74 +218,25 @@
+ @foreach($alsoPurchased as $product)
- Front of men's Basic Tee in black. -
-
-
-

- - - Basic Tee - -

-

Black

-
-

$35

-
-
-
-
- Front of men's Basic Tee in white. -
-
-
-

- - - Basic Tee - -

-

Aspen White

-
-

$35

-
-
-
-
- Front of men's Basic Tee in dark gray. -
-
-
-

- - - Basic Tee - -

-

Charcoal

-
-

$35

-
-
-
-
- Front of men's Artwork Tee in peach with white and brown dots forming an isometric cube. + Front of men's Artwork Tee in peach with white and brown dots forming an isometric cube.
-

$35

+

${{ $product->price }}

+ @endforeach
diff --git a/routes/web.php b/routes/web.php index c5a37d9..81758b7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -26,8 +26,8 @@ Route::get('/', [HomePageController::class, 'index'])->name('home'); Route::get('collections', [CollectionController::class, 'index'])->name('collections'); -Route::get('collections/category', [CollectionController::class, 'products'])->name('collections.products'); -Route::get('collections/category/product', [CollectionController::class, 'show'])->name('collections.products.show'); +Route::get('collections/{category:slug}', [CollectionController::class, 'products'])->name('collections.products'); +Route::get('collections/{category:slug}/{product:slug}', [CollectionController::class, 'show'])->name('product.show'); Route::get('cart', [CartController::class, 'index'])->name('cart'); Route::get('checkout', [CheckoutController::class, 'index'])->name('checkout');