Commit cada8274 authored by TTS Tran Viet Anh's avatar TTS Tran Viet Anh

index

parent 241193f5
<?php
namespace App\Http\Controllers;
use App\Models\Post;
use App\Models\Product;
use App\Models\ProductCategory;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$productCategories = ProductCategory::query()->get();
$latestDrops = Product::query()
->with('productAttributes')
->where('status', '=', Product::STATUS_ENABLE)
->latest()
->take(4)
->get();
$products = Product::query()->take(8)->get();
$latestBlogs = Post::query()
->with('user')
->latest()
->take(3)
->get();
return view('client.index', compact('latestDrops', 'productCategories', 'products', 'latestBlogs'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
public function getProductsByCategory(Request $request)
{
$categoryID = $request->productCategoryID;
$productsByCategory = Product::query()
->where('product_category_id', '=', $categoryID)
->latest()
->take(8)
->get();
return view('client.products_by_category', compact('productsByCategory'));
}
}
@extends('layout.app')
@section('content')
{{-- Carousel --}}
<div id="carouselExampleControls" class="carousel carousel-dark slide" data-bs-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="{{ asset('assets') }}/images/1.jpg" class="d-block w-100" alt="...">
<div class="carousel-caption d-md-block">
<h4>First slide label</h4>
<span>Some representative placeholder content for the first slide.</span>
</div>
</div>
<div class="carousel-item">
<img src="{{ asset('assets') }}/images/2.jpg" class="d-block w-100" alt="...">
<div class="carousel-caption d-md-block">
<h4>Second slide label</h4>
<span>Some representative placeholder content for the second slide.</span>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
{{-- Sub banner --}}
<div class="row m-5">
<div class="col">
<img src="{{ asset('assets') }}/images/sub-banner1.jpg" class="d-block w-100" alt="...">
</div>
<div class="col">
<img src="{{ asset('assets') }}/images/sub-banner2.jpg" class="d-block w-100" alt="...">
</div>
</div>
{{-- Latest Drops --}}
<div class="container">
<div class="text-center">
<span>Special offer</span>
<h2>Latest Drops</h2>
<p class="mt-4">
Looking for the latest trends in clothing, shoes and accessories? <br>
Welcome to our 'Latest Drops' edit, bringing you all the latest styles from all your fave brands.
</p>
</div>
<div class="container">
<div class="row">
@foreach ($latestDrops as $latestDrop)
<div class="col">
<div class="card">
<img src="{{ $latestDrop->image }}" class="card-img-top" alt="...">
<div class="card-body">
{{-- rating --}}
<div class="rating">
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star"></span>
</div>
{{-- rating --}}
<h6 class="card-title">{{ $latestDrop->name }}</h6>
<h5>{{ $latestDrop->price }}</h5>
<div class="color">
@foreach ($latestDrop->productAttributes as $productAttribute)
<span class="dot mx-"
style="height: 20px; width: 20px;background-color:{{ $productAttribute->color }}; border-radius: 50%;
display: inline-block;"></span>
@endforeach
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
{{-- Banner --}}
<div class="my-5"
style="background: url('{{ asset('assets') }}/images/bg1.jpg'); background-size: cover; height:500px ">
</div>
{{-- Product --}}
<div class="container">
<div class="text-center">
<span>Exclusive Products</span>
<h2>Everyday Casual</h2>
<ul style="list-style: none;">
@foreach ($productCategories as $productCategory)
<li class="mx-3" style="display: inline-block; cursor: pointer">
<h6 id="productCategory{{ $productCategory->id }}">
{{ $productCategory->name }}
</h6>
</li>
<script>
$(document).ready(function() {
$('#productCategory{{ $productCategory->id }}').click(function() {
$.ajax({
type: "GET",
url: "{{ route('productsByCategory') }}",
data: {
productCategoryID: {{ $productCategory->id }},
},
success: function(data) {
$('#productsByCategory').html(data);
}
});
});
});
</script>
@endforeach
</ul>
</div>
<div class="container" id="productsByCategory">
<div class="row">
@foreach ($products as $product)
<div class="col-3 my-2">
<div class="card">
<img src="{{ $product->image }}" class="card-img-top" alt="...">
<div class="card-body">
{{-- rating --}}
<div class="rating">
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star"></span>
</div>
{{-- rating --}}
<h6 class="card-title">{{ $product->name }}</h6>
<h5>{{ $product->price }}</h5>
<div class="color">
@foreach ($product->productAttributes as $productAttribute)
<span class="dot mx-"
style="height: 20px; width: 20px;background-color:{{ $productAttribute->color }}; border-radius: 50%;
display: inline-block;"></span>
@endforeach
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
{{-- Service --}}
<div class="container">
<section class="d-flex justify-content-lg-between p-5 m-5 border-bottom border-top">
<div class="me-5 d-lg-block">
<h6>Free Shipping</h6>
<span>Free Shipping World Wide</span>
</div>
<div class="vr"></div>
<div class="me-5 d-lg-block">
<h6>24 X 7 Service</h6>
<span>Online Service For New Customer</span>
</div>
<div class="vr"></div>
<div class="me-5 d-lg-block">
<h6>Festival Offer</h6>
<span>New Online Special Festival Offer</span>
</div>
</section>
</div>
{{-- Blog --}}
<div class="container">
<div class="text-center">
<span class="mb-3">From The Blog</span>
<h2 class="mb-4">FASHION FOR YOU</h2>
</div>
<div class="container">
<div class="row">
@foreach ($latestBlogs as $blog)
<div class="col-4">
<div class="card border-0">
<img src="{{ $blog->image }}" class="card-img-top" alt="...">
<div class="card-body">
<h6 class="card-title">{{ $blog->publish_date }}</h6>
<h5>{{ $blog->title }}</h5>
<span>by: {{ $blog->user->name }}</span>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
</div>
@endsection
<div class="row">
@foreach ($productsByCategory as $productByCategory)
<div class="col-3">
<div class="card">
<img src="{{ $productByCategory->image }}" class="card-img-top" alt="...">
<div class="card-body">
{{-- rating --}}
<div class="rating">
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star" style="color:orange"></span>
<span class="fa fa-star"></span>
</div>
{{-- rating --}}
<h6 class="card-title">{{ $productByCategory->name }}</h6>
<h5>{{ $productByCategory->price }}</h5>
<div class="color">
@foreach ($productByCategory->productAttributes as $productAttribute)
<span class="dot mx-"
style="height: 20px; width: 20px;background-color:{{ $productAttribute->color }}; border-radius: 50%;
display: inline-block;"></span>
@endforeach
</div>
</div>
</div>
</div>
@endforeach
</div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
{{-- boostrap --}}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous">
</script>
{{-- fontawsome --}}
<script src="https://kit.fontawesome.com/47b2d8ad40.js" crossorigin="anonymous"></script>
{{-- Jquery --}}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<title>Document</title>
</head>
<body>
{{-- Navbar --}}
@include('layout.navbar')
{{-- Navbar --}}
{{-- Content --}}
<div class="wrapper">
<div class="content">
@yield('content')
</div>
</div>
{{-- Content --}}
<!-- Footer -->
@include('layout.footer')
<!-- Footer -->
</body>
</html>
<footer class="text-center text-lg-start bg-light text-muted">
<!-- Section: Social media -->
<section class="container d-flex justify-content-center justify-content-lg-between p-4 border-bottom">
<!-- Left -->
<div class="me-5 d-none d-lg-block">
<h5>KNOW IT ALL FIRST!</h5>
<span>Never Miss Anything From Multikart By Signing Up To Our Newsletter.</span>
</div>
<!-- Left -->
<div class="vr"></div>
<!-- Right -->
<div class="form-group mb-3">
<div class="input-group">
<input type="text" class="form-control" placeholder="Recipient's username"
aria-label="Recipient's username" aria-describedby="button-addon2">
<button class="btn btn-outline-secondary" type="button" id="button-addon2">Button</button>
</div>
</div>
<!-- Right -->
</section>
<!-- Section: Social media -->
<!-- Section: Links -->
<section class="container border-bottom">
<div class="container text-center text-md-start mt-5">
<!-- Grid row -->
<div class="row mt-3">
<!-- Grid column -->
<div class="col-md-3 col-lg-4 col-xl-3 mx-auto mb-4">
<!-- Content -->
<h6 class="text-uppercase fw-bold mb-4">
<img src="{{ asset('assets') }}/images/logo.png" alt="" srcset="">
</h6>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam,
</p>
<div>
<a href="" class="me-4 text-reset">
<i class="fab fa-facebook-f"></i>
</a>
<a href="" class="me-4 text-reset">
<i class="fab fa-twitter"></i>
</a>
<a href="" class="me-4 text-reset">
<i class="fab fa-google"></i>
</a>
<a href="" class="me-4 text-reset">
<i class="fab fa-instagram"></i>
</a>
<a href="" class="me-4 text-reset">
<i class="fab fa-linkedin"></i>
</a>
<a href="" class="me-4 text-reset">
<i class="fab fa-github"></i>
</a>
</div>
</div>
<!-- Grid column -->
<!-- Grid column -->
<div class="col-md-2 col-lg-2 col-xl-2 mx-auto mb-4">
<!-- Links -->
<h6 class="text-uppercase fw-bold mb-4">
My Account
</h6>
<p>
<a href="#!" class="text-reset">Mens</a>
</p>
<p>
<a href="#!" class="text-reset">Womens</a>
</p>
<p>
<a href="#!" class="text-reset">Clothing</a>
</p>
<p>
<a href="#!" class="text-reset">Accessories</a>
</p>
<p>
<a href="#!" class="text-reset">Featured</a>
</p>
</div>
<!-- Grid column -->
<!-- Grid column -->
<div class="col-md-3 col-lg-2 col-xl-2 mx-auto mb-4">
<!-- Links -->
<h6 class="text-uppercase fw-bold mb-4">
Why We Choose
</h6>
<p>
<a href="#!" class="text-reset">Shipping & Return</a>
</p>
<p>
<a href="#!" class="text-reset">Secure Shopping</a>
</p>
<p>
<a href="#!" class="text-reset">Gallary</a>
</p>
<p>
<a href="#!" class="text-reset">Gallary</a>
</p>
<p>
<a href="#!" class="text-reset">Contacts</a>
</p>
</div>
<!-- Grid column -->
<!-- Grid column -->
<div class="col-md-4 col-lg-3 col-xl-3 mx-auto mb-md-0 mb-4">
<!-- Links -->
<h6 class="text-uppercase fw-bold mb-4">Store Infomation</h6>
<p>
<i class="fa-solid fa-location-dot fa-xs"></i>
Multikart Demo Store, Demo Store India 345-659
</p>
<p>
<i class="fas fa-phone me-3 fa-xs"></i>
Call Us: 123-456-7898
</p>
<p>
<i class="fas fa-envelope me-3 fa-xs"></i>
Email Us: Support@Fiot.Com
</p>
<p>
<i class="fa-solid fa-fax fa-xs"></i>
Fax: 123456
</p>
</div>
<!-- Grid column -->
</div>
<!-- Grid row -->
</div>
</section>
<!-- Section: Links -->
<!-- Copyright -->
<div class="text-center p-4">
<div class="row">
<div class="col">© 2017-18 themeforest powered by pixelstrap</div>
<div class="col">
<img src="{{ asset('assets') }}/images/american-express.png" alt="" class="ms-3">
<img src="{{ asset('assets') }}/images/visa.png" alt="" class="ms-3">
<img src="{{ asset('assets') }}/images/discover.png" alt="" class="ms-3">
<img src="{{ asset('assets') }}/images/mastercard.png" alt="" class="ms-3">
<img src="{{ asset('assets') }}/images/paypal.png" alt="" class="ms-3">
</div>
</div>
</div>
<!-- Copyright -->
</footer>
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="{{ asset('assets') }}/images/logo.png" alt="" srcset="">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
Feature
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
Product
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
Blog
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#" role="button">
Cart
</a>
</li>
</ul>
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<?php
use App\Http\Controllers\HomeController;
use Illuminate\Support\Facades\Route;
/*
......@@ -13,6 +14,7 @@
|
*/
Route::get('/', function () {
return view('welcome');
Route::controller(HomeController::class)->group(function () {
Route::get('/', 'index');
Route::get('/productsByCategory', 'getProductsByCategory')->name('productsByCategory');
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment