Skip to content

Commit

Permalink
Make pages dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
iambasanta committed Jun 5, 2023
1 parent 39405ea commit 259ec60
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 261 deletions.
10 changes: 7 additions & 3 deletions app/Http/Controllers/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Category;
use App\Models\Product;
use Illuminate\Http\Request;

class CollectionController extends Controller
Expand All @@ -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'));
}
}
4 changes: 3 additions & 1 deletion app/Http/Controllers/HomePageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
6 changes: 3 additions & 3 deletions resources/views/components/frontend/footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<h3 class="text-sm font-medium text-gray-900">Products</h3>
<ul role="list" class="mt-6 space-y-6">
<li class="text-sm">
<a href="#" class="text-gray-500 hover:text-gray-600">Clothing</a>
<a href="{{ route('collections.products', 'clothing') }}" class="text-gray-500 hover:text-gray-600">Clothing</a>
</li>
<li class="text-sm">
<a href="#" class="text-gray-500 hover:text-gray-600">Shoes</a>
<a href="{{ route('collections.products', 'shoes') }}" class="text-gray-500 hover:text-gray-600">Shoes</a>
</li>
<li class="text-sm">
<li class="text-sm">
<a href="#" class="text-gray-500 hover:text-gray-600">Accessories</a>
<a href="{{ route('collections.products', 'accessories') }}" class="text-gray-500 hover:text-gray-600">Accessories</a>
</li>
</ul>
</div>
Expand Down
28 changes: 17 additions & 11 deletions resources/views/components/frontend/nav.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
<div class="aspect-h-1 aspect-w-1 overflow-hidden rounded-md bg-gray-100 group-hover:opacity-75">
<img src="{{ asset('assets/images/category-new-arrival.jpg') }}" alt="Hats and sweaters on wood shelves next to various colors of t-shirts on hangers." class="object-cover object-center">
</div>
<a href="#" class="mt-6 block text-sm font-medium text-gray-900">
<a href="{{ route('collections') }}" class="mt-6 block text-sm font-medium text-gray-900">
<span class="absolute inset-0 z-10" aria-hidden="true"></span>
New Arrivals
</a>
<p aria-hidden="true" class="mt-1 text-sm text-gray-500">Shop now</p>
</div>
<div class="group relative">
<div class="aspect-h-1 aspect-w-1 overflow-hidden rounded-md bg-gray-100 group-hover:opacity-75">
<img src="{{ asset('assets/images/category-clothing.jpg') }}" alt="Model wearing light heather gray t-shirt." class="object-cover object-center">
<img src="{{ asset('assets/images/category-clothing.jpg') }}" alt="Model putting folded cash into slim card holder olive leather wallet with hand stitching." class="object-cover object-center">
</div>
<a href="#" class="mt-6 block text-sm font-medium text-gray-900">
<a href="{{ route('collections.products', 'clothing') }}" class="mt-6 block text-sm font-medium text-gray-900">
<span class="absolute inset-0 z-10" aria-hidden="true"></span>
Clothing
</a>
Expand All @@ -51,7 +51,7 @@
<div class="aspect-h-1 aspect-w-1 overflow-hidden rounded-md bg-gray-100 group-hover:opacity-75">
<img src="{{ asset('assets/images/category-shoes.jpg') }}" alt="Model putting folded cash into slim card holder olive leather wallet with hand stitching." class="object-cover object-center">
</div>
<a href="#" class="mt-6 block text-sm font-medium text-gray-900">
<a href="{{ route('collections.products', 'shoes') }}" class="mt-6 block text-sm font-medium text-gray-900">
<span class="absolute inset-0 z-10" aria-hidden="true"></span>
Shoes
</a>
Expand All @@ -61,7 +61,7 @@
<div class="aspect-h-1 aspect-w-1 overflow-hidden rounded-md bg-gray-100 group-hover:opacity-75">
<img src="{{ asset('assets/images/category-accessories.jpg') }}" alt="Grey 6-panel baseball hat with black brim, black mountain graphic on front, and light heather gray body." class="object-cover object-center">
</div>
<a href="#" class="mt-6 block text-sm font-medium text-gray-900">
<a href="{{ route('collections.products', 'accessories') }}" class="mt-6 block text-sm font-medium text-gray-900">
<span class="absolute inset-0 z-10" aria-hidden="true"></span>
Accessories
</a>
Expand All @@ -77,10 +77,15 @@
<div class="flow-root">
<a href="#" class="-m-2 block p-2 font-medium text-gray-900">About</a>
</div>

<div class="flow-root">
<a href="#" class="-m-2 block p-2 font-medium text-gray-900">Contact</a>
</div>

<div class="flow-root">
<a href="#" class="-m-2 block p-2 font-medium text-gray-900">Help</a>
</div>

</div>

<div class="space-y-6 border-t border-gray-200 px-4 py-6">
Expand All @@ -106,7 +111,7 @@
<div class="flex h-16 items-center justify-between">
<!-- Logo (lg+) -->
<div class="hidden lg:flex lg:flex-1 lg:items-center">
<a href="#">
<a href="/">
<span class="sr-only">Your Company</span>
<x-application-logo/>
</a>
Expand Down Expand Up @@ -140,7 +145,7 @@
<div class="aspect-h-1 aspect-w-1 overflow-hidden rounded-md bg-gray-100 group-hover:opacity-75">
<img src="{{ asset('assets/images/category-new-arrival.jpg') }}" alt="Hats and sweaters on wood shelves next to various colors of t-shirts on hangers." class="object-cover object-center">
</div>
<a href="#" class="mt-4 block font-medium text-gray-900">
<a href="{{ route('collections') }}" class="mt-4 block font-medium text-gray-900">
<span class="absolute inset-0 z-10" aria-hidden="true"></span>
New Arrivals
</a>
Expand All @@ -150,7 +155,7 @@
<div class="aspect-h-1 aspect-w-1 overflow-hidden rounded-md bg-gray-100 group-hover:opacity-75">
<img src="{{ asset('assets/images/category-clothing.jpg') }}" alt="Model wearing light heather gray t-shirt." class="object-cover object-center">
</div>
<a href="#" class="mt-4 block font-medium text-gray-900">
<a href="{{ route('collections.products', 'clothing') }}" class="mt-4 block font-medium text-gray-900">
<span class="absolute inset-0 z-10" aria-hidden="true"></span>
Clothing
</a>
Expand All @@ -160,7 +165,7 @@
<div class="aspect-h-1 aspect-w-1 overflow-hidden rounded-md bg-gray-100 group-hover:opacity-75">
<img src="{{ asset('assets/images/category-shoes.jpg') }}" alt="Grey 6-panel baseball hat with black brim, black mountain graphic on front, and light heather gray body." class="object-cover object-center">
</div>
<a href="#" class="mt-4 block font-medium text-gray-900">
<a href="{{ route('collections.products', 'shoes') }}" class="mt-4 block font-medium text-gray-900">
<span class="absolute inset-0 z-10" aria-hidden="true"></span>
Shoes
</a>
Expand All @@ -170,7 +175,7 @@
<div class="aspect-h-1 aspect-w-1 overflow-hidden rounded-md bg-gray-100 group-hover:opacity-75">
<img src="{{ asset('assets/images/category-accessories.jpg') }}" alt="Model putting folded cash into slim card holder olive leather wallet with hand stitching." class="object-cover object-center">
</div>
<a href="#" class="mt-4 block font-medium text-gray-900">
<a href="{{ route('collections.products', 'accessories') }}" class="mt-4 block font-medium text-gray-900">
<span class="absolute inset-0 z-10" aria-hidden="true"></span>
Accessories
</a>
Expand All @@ -186,6 +191,7 @@

<a href="#" class="flex items-center text-sm font-medium text-gray-700 hover:text-gray-800">About</a>
<a href="#" class="flex items-center text-sm font-medium text-gray-700 hover:text-gray-800">Contact</a>
<a href="#" class="flex items-center text-sm font-medium text-gray-700 hover:text-gray-800">Help</a>

</div>
</div>
Expand All @@ -203,7 +209,7 @@
</div>

<!-- Logo (lg-) -->
<a href="#" class="lg:hidden">
<a href="/" class="lg:hidden">
<span class="sr-only">Your Company</span>
<x-application-logo/>
</a>
Expand Down
18 changes: 12 additions & 6 deletions resources/views/frontend/collections/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
<div class="mt-10 flow-root">
<div class="-my-2">
<div class="relative box-content h-80 overflow-x-auto py-2 xl:overflow-visible">
<div class="min-w-screen-xl absolute flex space-x-8 px-4 sm:px-6 lg:px-8 xl:relative xl:grid xl:grid-cols-5 xl:gap-x-8 xl:space-x-0 xl:px-0">
<a href="#" class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<div
class="min-w-screen-xl absolute flex space-x-8 px-4 sm:px-6 lg:px-8 xl:relative xl:grid xl:grid-cols-5 xl:gap-x-8 xl:space-x-0 xl:px-0">
<a href="{{ route('collections') }}"
class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<span aria-hidden="true" class="absolute inset-0">
<img src="{{ asset('assets/images/category-new-arrival.jpg') }}" alt=""
class="h-full w-full object-cover object-center">
Expand All @@ -16,7 +18,8 @@ class="h-full w-full object-cover object-center">
class="absolute inset-x-0 bottom-0 h-2/3 bg-gradient-to-t from-gray-800 opacity-50"></span>
<span class="relative mt-auto text-center text-xl font-bold text-white">New Arrivals</span>
</a>
<a href="#" class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<a href="{{ route('collections.products', 'clothing') }}"
class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<span aria-hidden="true" class="absolute inset-0">
<img src="{{ asset('assets/images/category-clothing.jpg') }}" alt=""
class="h-full w-full object-cover object-center">
Expand All @@ -25,7 +28,8 @@ class="h-full w-full object-cover object-center">
class="absolute inset-x-0 bottom-0 h-2/3 bg-gradient-to-t from-gray-800 opacity-50"></span>
<span class="relative mt-auto text-center text-xl font-bold text-white">Clothing</span>
</a>
<a href="#" class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<a href="{{ route('collections.products', 'shoes') }}"
class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<span aria-hidden="true" class="absolute inset-0">
<img src="{{ asset('assets/images/category-shoes.jpg') }}" alt=""
class="h-full w-full object-cover object-center">
Expand All @@ -34,7 +38,8 @@ class="h-full w-full object-cover object-center">
class="absolute inset-x-0 bottom-0 h-2/3 bg-gradient-to-t from-gray-800 opacity-50"></span>
<span class="relative mt-auto text-center text-xl font-bold text-white">Shoes</span>
</a>
<a href="#" class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<a href="{{ route('collections.products', 'accessories') }}"
class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<span aria-hidden="true" class="absolute inset-0">
<img src="{{ asset('assets/images/category-accessories.jpg') }}" alt=""
class="h-full w-full object-cover object-center">
Expand All @@ -43,7 +48,8 @@ class="h-full w-full object-cover object-center">
class="absolute inset-x-0 bottom-0 h-2/3 bg-gradient-to-t from-gray-800 opacity-50"></span>
<span class="relative mt-auto text-center text-xl font-bold text-white">Accessories</span>
</a>
<a href="#" class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<a href="{{ route('collections') }}"
class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<span aria-hidden="true" class="absolute inset-0">
<img src="{{ asset('assets/images/category-sale.jpg') }}" alt=""
class="h-full w-full object-cover object-center">
Expand Down
Loading

0 comments on commit 259ec60

Please sign in to comment.