Commit 4c4e5f7c by Hussain Mohamed

changes

parent 1ba39d4d
......@@ -4,9 +4,11 @@
use App\Http\Controllers\Controller;
use App\Models\BrandProduct;
use App\Models\Country;
use App\Models\Currency;
use App\Models\DistanceRequest;
use App\Models\IndustryProduct;
use App\Models\WebRequestModel;
use App\Models\LanguageModel;
use App\Models\ManageRequestModel;
......@@ -20,9 +22,13 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Settings;
use App\Models\SizeModel;
use App\Models\SizeProduct;
use App\Models\SliderModel;
use Google\Service\AdExchangeBuyer\Product;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
class FrontendController extends Controller
{
......@@ -47,6 +53,42 @@ public function products()
return view('products',compact('productType','brandData','industryData'));
}
public function getProduct($name='')
{
$product = ProductModel::Where('product_slug',$name)->first();
$id = isset($product->id) ? $product->id:0;
if($id != '')
{
$brands = BrandProduct::from('product_brand as pb')
->leftJoin('brand as b', 'b.id', '=', 'pb.brand_id')
->where('pb.product_id', $id)
->select('b.brand','b.id')
->get();
$industrys = IndustryProduct::from('product_industry as pb')
->leftJoin('industry as b', 'b.id', '=', 'pb.industry_id')
->where('pb.product_id', $id)
->select('b.industry','b.id')
->get();
$size = SizeProduct::from('product_size as pb')
->leftJoin('size as b', 'b.id', '=', 'pb.size_id')
->where('pb.product_id', $id)
->select('b.size','b.id')
->get();
return view('product_detail',compact('product','size','industrys','brands'));
}
// $records = ProductModel::get();
// foreach($records as $row)
// {
// ProductModel::Where('id',$row->id)->update(array('product_slug'=>Str::slug($row->product_name)));
// }
}
public function getAjaxProducts(Request $request)
{
$offset = $request->get('offset', 0);
......
......@@ -17,5 +17,11 @@ public function category()
}
// public function brand()
// {
// return $this->belongsToMany(ProductBrandModel::class,'product_brand','product_id', 'brand_id');
// }
}
......@@ -5262,16 +5262,22 @@ section,
color: #333;
}
.filter-accordion .accordion-body div.active {
font-weight: 600;
color: #fff;
background: #024959;
text-align: center;
.filter-accordion .accordion-body div.active {
color: #282828;
background: #eeeeee;
margin-right: 5px;
border-radius: 12px;
font-weight: 400;
width: 60%;
}
#brand .accordion-body {
#brand .accordion-body {
max-height: 250px;
overflow-y: auto;
}
#industry .accordion-body {
max-height: 250px;
overflow-y: auto;
}
......@@ -5309,6 +5315,19 @@ h2.htwo {
animation: dotPulse .65s 0s infinite cubic-bezier(.21, .53, .56, .8);
}
/* Infinite Scrolling */
.et-loader {
position: relative;
padding-bottom: 30px;
margin-bottom: 30px;
}
.et-loader:after {
top: auto;
bottom: 0;
}
@keyframes dotPulse {
0% {
-webkit-transform:scale(.1);
......@@ -5329,3 +5348,11 @@ h2.htwo {
transform:scale(1.2);
opacity:0 }
}
.plink{
color:#282828;
font-size: 14px;;
}
.plink:hover{
color:#282828;
}
\ No newline at end of file
<?php
use Illuminate\Support\Str;
if (isset($records)) {
foreach ($records as $key => $row) { ?>
<div class="col-lg-4 col-md-6 col-sm-12">
<div class="product-card text-center">
<a class="plink" href="<?= route('products',[Str::slug($row->product_name)]) ?>"><div class="product-card text-center">
<img src="<?= ($row->product_image == '') ? asset('assets/img/placeholder.png'):$row->product_image ?>" class="img-fluid product-img" alt="Product">
<h6 class="product-title mt-3"><?= ucwords($row->product_name) ?></h6>
</div>
</a>
</div>
<?php }
}
......
@extends('app_layout')
@section('title','Contact Us')
@section('content')
<main class="main">
<div class="page-title ">
<div class="container">
<div class="row g-4">
<h1 class="hfive text-center">Products</h1>
<div class="col-lg-6">
</div>
<div class="col-lg-6">
<div class="container py-4">
<div class="row g-4" id="productList">
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
\ No newline at end of file
......@@ -22,8 +22,8 @@
<div class="accordion-body">
<?php if (isset($productType)) {
foreach ($productType as $row) { ?>
<div><?= $row->type ?></div>
<?php }
<div><?php echo $row->type ?></div>
<?php }
} ?>
</div>
</div>
......@@ -42,8 +42,8 @@
<div class="accordion-body">
<?php if (isset($industryData)) {
foreach ($industryData as $row) { ?>
<div><?= $row->industry ?></div>
<?php }
<div><?php echo $row->industry ?></div>
<?php }
} ?>
</div>
</div>
......@@ -62,8 +62,8 @@
<div class="accordion-body">
<?php if (isset($brandData)) {
foreach ($brandData as $row) { ?>
<div><?= $row->brand ?></div>
<?php }
<div><?php echo $row->brand ?></div>
<?php }
} ?>
</div>
</div>
......@@ -75,14 +75,11 @@
<div class="col-lg-8">
<div class="container py-4">
<div class="row g-4" id="productList">
</div>
<div class="text-center mt-4">
<button id="loadMore"
class="btn btn-outline-dark">
Load More
</button>
<span id="loadMore" class="btn et-loader"></span>
</div>
</div>
......@@ -106,41 +103,52 @@
let offset = 0;
const limit = 6;
function loadProducts(reset = false) {
if (reset) {
offset = 0;
$('#productList').html('');
}
$.ajax({
url: '<?= route('getProducts') ?>',
type: 'GET',
data: {
offset: offset,
limit: limit
},
success: function (data) {
// if (data.length === 0) {
// $('#loadMore').hide();
// return;
// }
$('#productList').append(data);
offset += limit;
const limit = 6;
$('#loadMore').hide();
function loadProducts(reset = false) {
if (reset) {
offset = 0;
$('#productList').html('');
}
$('#loadMore').show();
$.ajax({
url: '<?php echo route('getProducts') ?>',
type: 'GET',
data: {
offset: offset,
limit: limit
},
success: function(data) {
// if (data.length === 0) {
// $('#loadMore').hide();
// return;
// }
$('#loadMore').hide();
$('#productList').append(data);
offset += limit;
}
});
}
});
}
// Initial Load
loadProducts();
// Initial Load
loadProducts();
$(window).on('scroll', function() {
if (
$(window).scrollTop() + $(window).height() >=
$(document).height() - 100
) {
loadProducts();
}
});
// Load More Click
$('#loadMore').on('click', function () {
loadProducts();
});
// Load More Click
// $('#loadMore').on('click', function () {
// loadProducts();
// });
</script>
......
......@@ -28,6 +28,7 @@
Route::get('about-us', [FrontendController::class, 'about'])->name('about-us');
Route::get('career', [FrontendController::class, 'career'])->name('career');
Route::get('product', [FrontendController::class, 'products'])->name('product');
Route::get('products/{name?}', [FrontendController::class, 'getProduct'])->name('products');
Route::match(['get','post'],'getProducts', [FrontendController::class, 'getAjaxProducts'])->name('getProducts');
......
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