Commit c15dcfae by Hussain Mohamed

Changes

parent d448e525
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
use App\Models\SizeModel; use App\Models\SizeModel;
use App\Models\SizeProduct; use App\Models\SizeProduct;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\URL;
class ProductController extends Controller class ProductController extends Controller
...@@ -37,17 +38,90 @@ public function addProduct($id = '') ...@@ -37,17 +38,90 @@ public function addProduct($id = '')
if ($id > 0) { if ($id > 0) {
$record = ProductModel::Where('id', $id)->first(); $record = ProductModel::Where('id', $id)->first();
$productItems = ProductAttributeModel::Where('product_id', $id)->get(); $productItems = ProductAttributeModel::Where('product_id', $id)->get();
$sizeAr = SizeProduct::Where('product_id',$id)->pluck('size_id')->toArray(); $sizeAr = SizeProduct::Where('product_id', $id)->pluck('size_id')->toArray();
$brandAr = BrandProduct::Where('product_id',$id)->pluck('brand_id')->toArray(); $brandAr = BrandProduct::Where('product_id', $id)->pluck('brand_id')->toArray();
$indusAr = IndustryProduct::Where('product_id',$id)->pluck('industry_id')->toArray(); $indusAr = IndustryProduct::Where('product_id', $id)->pluck('industry_id')->toArray();
$categoryAr = CategoryProduct::Where('product_id',$id)->pluck('category_id')->toArray(); $categoryAr = CategoryProduct::Where('product_id', $id)->pluck('category_id')->toArray();
return view('backend.products.edit', compact('brandAr','indusAr','categoryAr','sizeAr','record', 'productItems', 'categoryData', 'sizeData', 'brandData', 'typeData', 'industryData')); return view('backend.products.edit', compact('brandAr', 'indusAr', 'categoryAr', 'sizeAr', 'record', 'productItems', 'categoryData', 'sizeData', 'brandData', 'typeData', 'industryData'));
} else { } else {
return view('backend.products.add', compact('categoryData', 'sizeData', 'typeData', 'brandData', 'industryData')); return view('backend.products.add', compact('categoryData', 'sizeData', 'typeData', 'brandData', 'industryData'));
} }
} }
public function uploadProducts(Request $request)
{
$file = $request->file('products');
if (!$file || !$file->isValid()) {
return back()->with('error', 'Invalid file');
}
if ($file->isValid()) {
$filename = $file->getRealPath();
$handle = fopen($filename, 'r');
// if (($handle = fopen($filename, 'r')) !== false) {
fgetcsv($handle);
while (($importData = fgetcsv($handle, 10000, ",")) !== false) {
if ($importData[0] !== 'S.NO') {
$name = stripslashes($importData[1]);
$category = stripslashes($importData[2]);
$industry = array_map(fn($v) => trim($v), explode("/", stripslashes(trim($importData[3]))));
$brand = array_map(fn($v) => trim($v), explode("/", stripslashes($importData[4])));
$size = array_map(fn($v) => trim($v), explode("/", stripslashes($importData[5])));
DB::enableQueryLog();
$sizeId = SizeModel::WhereIn('size', $size)->pluck('id')->toArray();
$industryId = ProductIndustryModel::WhereIn('industry', $industry)->pluck('id')->toArray();
$brandId = ProductBrandModel::WhereIn('brand', $brand)->pluck('id')->toArray();
$categoryId = CategoryModel::Where('category_name', trim($category))->value('id');
$insertArr = array(
'product_name' => $name,
);
$insert = ProductModel::create($insertArr);
if ($insert['id'] > 0) {
$cateAr = array(
'product_id' => $insert['id'],
'category_id' => $categoryId
);
CategoryProduct::create($cateAr);
foreach ($industryId as $val) {
$indusarr = array(
'product_id' => $insert['id'],
'industry_id' => $val
);
IndustryProduct::create($indusarr);
}
foreach ($brandId as $val) {
$brandarr = array(
'product_id' => $insert['id'],
'brand_id' => $val
);
BrandProduct::create($brandarr);
}
foreach ($sizeId as $val) {
$sizearr = array(
'product_id' => $insert['id'],
'size_id' => $val
);
SizeProduct::create($sizearr);
}
}
}
}
fclose($handle);
// }
}
}
public function storeUpdateproducts(Request $request) public function storeUpdateproducts(Request $request)
{ {
$input = $request->all(); $input = $request->all();
...@@ -148,7 +222,6 @@ public function storeUpdateproducts(Request $request) ...@@ -148,7 +222,6 @@ public function storeUpdateproducts(Request $request)
$broucher->move(public_path('/uploads/broucher/'), $broucherName); $broucher->move(public_path('/uploads/broucher/'), $broucherName);
$broucherUrl = URL::to('/') . '/uploads/broucher/' . $broucherName; $broucherUrl = URL::to('/') . '/uploads/broucher/' . $broucherName;
$insertArr['broucher'] = $broucherUrl; $insertArr['broucher'] = $broucherUrl;
} }
$update = ProductModel::Where('id', $id)->update($insertArr); $update = ProductModel::Where('id', $id)->update($insertArr);
...@@ -157,37 +230,37 @@ public function storeUpdateproducts(Request $request) ...@@ -157,37 +230,37 @@ public function storeUpdateproducts(Request $request)
BrandProduct::Where('product_id', $id)->delete(); BrandProduct::Where('product_id', $id)->delete();
SizeProduct::Where('product_id', $id)->delete(); SizeProduct::Where('product_id', $id)->delete();
foreach ($category_id as $val) { foreach ($category_id as $val) {
$cateAr = array( $cateAr = array(
'product_id' => $id, 'product_id' => $id,
'category_id' => $val 'category_id' => $val
); );
CategoryProduct::create($cateAr); CategoryProduct::create($cateAr);
} }
foreach ($industry_id as $val) { foreach ($industry_id as $val) {
$indusarr = array( $indusarr = array(
'product_id' => $id, 'product_id' => $id,
'industry_id' => $val 'industry_id' => $val
); );
IndustryProduct::create($indusarr); IndustryProduct::create($indusarr);
} }
foreach ($brand_id as $val) { foreach ($brand_id as $val) {
$brandarr = array( $brandarr = array(
'product_id' => $id, 'product_id' => $id,
'brand_id' => $val 'brand_id' => $val
); );
BrandProduct::create($brandarr); BrandProduct::create($brandarr);
} }
foreach ($product_size as $val) { foreach ($product_size as $val) {
$sizearr = array( $sizearr = array(
'product_id' => $id, 'product_id' => $id,
'size_id' => $val 'size_id' => $val
); );
SizeProduct::create($sizearr); SizeProduct::create($sizearr);
} }
foreach ($item_id as $k => $val) { foreach ($item_id as $k => $val) {
if ($val == '' || $val == 0) { if ($val == '' || $val == 0) {
...@@ -206,15 +279,15 @@ public function storeUpdateproducts(Request $request) ...@@ -206,15 +279,15 @@ public function storeUpdateproducts(Request $request)
ProductAttributeModel::create($insertA); ProductAttributeModel::create($insertA);
} }
} else { } else {
/** if id is available new list will update */ /** if id is available new list will update */
if (isset($request->file('product_image')[$k])) { if (isset($request->file('product_image')[$k])) {
$image = $request->file('product_image')[$k]; $image = $request->file('product_image')[$k];
$imageName = 'product_image' . time() . '_' . str_replace(' ', '_', $image->getClientOriginalName()); $imageName = 'product_image' . time() . '_' . str_replace(' ', '_', $image->getClientOriginalName());
$image->move(public_path('/uploads/product_image/'), $imageName); $image->move(public_path('/uploads/product_image/'), $imageName);
$imageUrl = URL::to('/') . '/uploads/product_image/' . $imageName; $imageUrl = URL::to('/') . '/uploads/product_image/' . $imageName;
$updateAr['product_image'] = $imageUrl; $updateAr['product_image'] = $imageUrl;
ProductAttributeModel::Where('product_id', $id)->Where('id', $val)->update($updateAr); ProductAttributeModel::Where('product_id', $id)->Where('id', $val)->update($updateAr);
} }
} }
} }
return redirect()->route('products')->with('success', 'Product Updated Successfully'); return redirect()->route('products')->with('success', 'Product Updated Successfully');
......
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-xl-12 col-xxl-12"> <div class="col-xl-12 col-xxl-12">
<!-- <form method="POST" action="<?= route('uploadProducts') ?>" enctype="multipart/form-data">
@csrf
<input type="file" name="products" />
<input type="submit" name="upload" class="btn btn-info" />
</form> -->
<form method="POST" id="countryForm" action="<?= route('storeUpdateproducts') ?>" enctype="multipart/form-data"> <form method="POST" id="countryForm" action="<?= route('storeUpdateproducts') ?>" enctype="multipart/form-data">
@csrf @csrf
<div> <div>
......
...@@ -10,16 +10,17 @@ ...@@ -10,16 +10,17 @@
<?php if (isset($slidersData)) { <?php if (isset($slidersData)) {
foreach ($slidersData as $row) { ?> foreach ($slidersData as $row) { ?>
<div class="swiper-slide"> <div class="swiper-slide">
<div class="hero-slide-bg" style="background-image:url('<?= $row->slider_img ?>');"> <div class="hero-slide-bg" style="background-image:url('<?php echo $row->slider_img ?>');">
<div class="hero-overlay"></div> <div class="hero-overlay"></div>
<div class="hero-content"> <div class="hero-content">
<h1><?= $row->slider_caption ?></h1> <h1><?php echo $row->slider_caption ?></h1>
<h4><?= $row->slider_type ?></h4> <h4><?php echo $row->slider_type ?></h4>
<a href="#">View All</a> <a href="#">View All</a>
</div> </div>
</div> </div>
</div> </div>
<?php } } ?> <?php }
} ?>
</div> </div>
<!-- Pagination --> <!-- Pagination -->
<div class="swiper-pagination"></div> <div class="swiper-pagination"></div>
...@@ -29,11 +30,11 @@ ...@@ -29,11 +30,11 @@
</div> </div>
</section> </section>
<section class="container"> <section class="container">
<div class="row gy-4 visual-display-section"> <div class="row gy-4 visual-display-section">
<!-- LEFT CONTENT --> <!-- LEFT CONTENT -->
...@@ -55,35 +56,35 @@ ...@@ -55,35 +56,35 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="display-card large"> <div class="display-card large">
<img src="<?= asset('assets') ?>/img/signage-tv.png" class="img-fluid" alt=""> <img src="<?php echo asset('assets') ?>/img/signage-tv.png" class="img-fluid" alt="">
<div class="display-title">Signage Display</div> <div class="display-title">Signage Display</div>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="display-card large"> <div class="display-card large">
<img src="<?= asset('assets') ?>/img/portable-projectors.png" class="img-fluid" alt=""> <img src="<?php echo asset('assets') ?>/img/portable-projectors.png" class="img-fluid" alt="">
<div class="display-title">Projectors</div> <div class="display-title">Projectors</div>
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="display-card small"> <div class="display-card small">
<img src="<?= asset('assets') ?>/img/led-wall.png" class="img-fluid" alt=""> <img src="<?php echo asset('assets') ?>/img/led-wall.png" class="img-fluid" alt="">
<div class="display-title">LED Wall</div> <div class="display-title">LED Wall</div>
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="display-card small"> <div class="display-card small">
<img src="<?= asset('assets') ?>/img/interactive-display.png" class="img-fluid" alt=""> <img src="<?php echo asset('assets') ?>/img/interactive-display.png" class="img-fluid" alt="">
<div class="display-title">Interactive Displays</div> <div class="display-title">Interactive Displays</div>
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="display-card small"> <div class="display-card small">
<img src="<?= asset('assets') ?>/img/digital-writing-pad.png" class="img-fluid" alt=""> <img src="<?php echo asset('assets') ?>/img/digital-writing-pad.png" class="img-fluid" alt="">
<div class="display-title">Digital Writing Pad</div> <div class="display-title">Digital Writing Pad</div>
</div> </div>
</div> </div>
...@@ -94,7 +95,7 @@ ...@@ -94,7 +95,7 @@
</section> </section>
<section class="container"> <section class="container">
<div class="achievements-banner" data-aos="zoom-in" data-aos-delay="700"> <div class="achievements-banner" data-aos="zoom-in" data-aos-delay="700">
<div class="row text-center"> <div class="row text-center">
<div class="col-lg-3 col-sm-6"> <div class="col-lg-3 col-sm-6">
...@@ -142,7 +143,7 @@ ...@@ -142,7 +143,7 @@
<a href="#" class="btn btn-outline-dark">See All</a> <a href="#" class="btn btn-outline-dark">See All</a>
</div> </div>
<div class="col-md-5 text-end"> <div class="col-md-5 text-end">
<img src="<?= asset('assets') ?>/img/monitor-3.png" class="img-fluid" alt="Monitors"> <img src="<?php echo asset('assets') ?>/img/monitor-3.png" class="img-fluid" alt="Monitors">
</div> </div>
</div> </div>
</div> </div>
...@@ -158,7 +159,7 @@ ...@@ -158,7 +159,7 @@
<a href="#" class="btn btn-outline-light">See All</a> <a href="#" class="btn btn-outline-light">See All</a>
</div> </div>
<div class="col-md-5 text-end"> <div class="col-md-5 text-end">
<img src="<?= asset('assets') ?>/img/aircon.png" class="img-fluid" alt="Aircon"> <img src="<?php echo asset('assets') ?>/img/aircon.png" class="img-fluid" alt="Aircon">
</div> </div>
</div> </div>
</div> </div>
...@@ -174,7 +175,7 @@ ...@@ -174,7 +175,7 @@
<a href="#" class="btn btn-outline-light">See All</a> <a href="#" class="btn btn-outline-light">See All</a>
</div> </div>
<div class="col-md-5 text-end"> <div class="col-md-5 text-end">
<img src="<?= asset('assets') ?>/img/small-appliances.png" class="img-fluid" alt="Appliances"> <img src="<?php echo asset('assets') ?>/img/small-appliances.png" class="img-fluid" alt="Appliances">
</div> </div>
</div> </div>
</div> </div>
...@@ -190,7 +191,7 @@ ...@@ -190,7 +191,7 @@
<a href="#" class="btn btn-outline-dark">See All</a> <a href="#" class="btn btn-outline-dark">See All</a>
</div> </div>
<div class="col-md-5 text-end"> <div class="col-md-5 text-end">
<img src="<?= asset('assets') ?>/img/accessories.png" class="img-fluid" alt="Accessories"> <img src="<?php echo asset('assets') ?>/img/accessories.png" class="img-fluid" alt="Accessories">
</div> </div>
</div> </div>
</div> </div>
...@@ -199,5 +200,13 @@ ...@@ -199,5 +200,13 @@
</div> </div>
</section> </section>
<section class="container" data-aos="fade-up" data-aos-delay="100">
<div class="row g-4">
<h1 class="text-center hfive">Our Brands</h1>
<p class="text-center">Palaniappa Electornics offers a wide range of trusted brands to choose from.</p>
<img src="<?= asset('assets/img/') ?>/brand.png" />
</div>
</section>
@endsection @endsection
\ No newline at end of file
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
Route::get('products', [ProductController::class, 'products'])->name('products'); Route::get('products', [ProductController::class, 'products'])->name('products');
Route::get('addProduct/{id?}', [ProductController::class, 'addProduct'])->name('addProduct'); Route::get('addProduct/{id?}', [ProductController::class, 'addProduct'])->name('addProduct');
Route::post('storeUpdateproducts', [ProductController::class, 'storeUpdateproducts'])->name('storeUpdateproducts'); Route::post('storeUpdateproducts', [ProductController::class, 'storeUpdateproducts'])->name('storeUpdateproducts');
Route::post('uploadProducts', [ProductController::class, 'uploadProducts'])->name('uploadProducts');
Route::get('size', [SizeController::class, 'size'])->name('size'); Route::get('size', [SizeController::class, 'size'])->name('size');
......
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