Commit c15dcfae by Hussain Mohamed

Changes

parent d448e525
......@@ -15,6 +15,7 @@
use App\Models\SizeModel;
use App\Models\SizeProduct;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\URL;
class ProductController extends Controller
......@@ -37,17 +38,90 @@ public function addProduct($id = '')
if ($id > 0) {
$record = ProductModel::Where('id', $id)->first();
$productItems = ProductAttributeModel::Where('product_id', $id)->get();
$sizeAr = SizeProduct::Where('product_id',$id)->pluck('size_id')->toArray();
$brandAr = BrandProduct::Where('product_id',$id)->pluck('brand_id')->toArray();
$indusAr = IndustryProduct::Where('product_id',$id)->pluck('industry_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'));
$sizeAr = SizeProduct::Where('product_id', $id)->pluck('size_id')->toArray();
$brandAr = BrandProduct::Where('product_id', $id)->pluck('brand_id')->toArray();
$indusAr = IndustryProduct::Where('product_id', $id)->pluck('industry_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'));
} else {
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)
{
$input = $request->all();
......@@ -148,7 +222,6 @@ public function storeUpdateproducts(Request $request)
$broucher->move(public_path('/uploads/broucher/'), $broucherName);
$broucherUrl = URL::to('/') . '/uploads/broucher/' . $broucherName;
$insertArr['broucher'] = $broucherUrl;
}
$update = ProductModel::Where('id', $id)->update($insertArr);
......@@ -157,37 +230,37 @@ public function storeUpdateproducts(Request $request)
BrandProduct::Where('product_id', $id)->delete();
SizeProduct::Where('product_id', $id)->delete();
foreach ($category_id as $val) {
$cateAr = array(
'product_id' => $id,
'category_id' => $val
);
CategoryProduct::create($cateAr);
}
foreach ($category_id as $val) {
$cateAr = array(
'product_id' => $id,
'category_id' => $val
);
CategoryProduct::create($cateAr);
}
foreach ($industry_id as $val) {
$indusarr = array(
'product_id' => $id,
'industry_id' => $val
);
IndustryProduct::create($indusarr);
}
foreach ($industry_id as $val) {
$indusarr = array(
'product_id' => $id,
'industry_id' => $val
);
IndustryProduct::create($indusarr);
}
foreach ($brand_id as $val) {
$brandarr = array(
'product_id' => $id,
'brand_id' => $val
);
BrandProduct::create($brandarr);
}
foreach ($brand_id as $val) {
$brandarr = array(
'product_id' => $id,
'brand_id' => $val
);
BrandProduct::create($brandarr);
}
foreach ($product_size as $val) {
$sizearr = array(
'product_id' => $id,
'size_id' => $val
);
SizeProduct::create($sizearr);
}
foreach ($product_size as $val) {
$sizearr = array(
'product_id' => $id,
'size_id' => $val
);
SizeProduct::create($sizearr);
}
foreach ($item_id as $k => $val) {
if ($val == '' || $val == 0) {
......@@ -206,15 +279,15 @@ public function storeUpdateproducts(Request $request)
ProductAttributeModel::create($insertA);
}
} else {
/** if id is available new list will update */
if (isset($request->file('product_image')[$k])) {
$image = $request->file('product_image')[$k];
$imageName = 'product_image' . time() . '_' . str_replace(' ', '_', $image->getClientOriginalName());
$image->move(public_path('/uploads/product_image/'), $imageName);
$imageUrl = URL::to('/') . '/uploads/product_image/' . $imageName;
$updateAr['product_image'] = $imageUrl;
ProductAttributeModel::Where('product_id', $id)->Where('id', $val)->update($updateAr);
}
/** if id is available new list will update */
if (isset($request->file('product_image')[$k])) {
$image = $request->file('product_image')[$k];
$imageName = 'product_image' . time() . '_' . str_replace(' ', '_', $image->getClientOriginalName());
$image->move(public_path('/uploads/product_image/'), $imageName);
$imageUrl = URL::to('/') . '/uploads/product_image/' . $imageName;
$updateAr['product_image'] = $imageUrl;
ProductAttributeModel::Where('product_id', $id)->Where('id', $val)->update($updateAr);
}
}
}
return redirect()->route('products')->with('success', 'Product Updated Successfully');
......
......@@ -18,6 +18,11 @@
</div>
<div class="row">
<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">
@csrf
<div>
......
......@@ -10,16 +10,17 @@
<?php if (isset($slidersData)) {
foreach ($slidersData as $row) { ?>
<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-content">
<h1><?= $row->slider_caption ?></h1>
<h4><?= $row->slider_type ?></h4>
<h1><?php echo $row->slider_caption ?></h1>
<h4><?php echo $row->slider_type ?></h4>
<a href="#">View All</a>
</div>
</div>
</div>
<?php } } ?>
<?php }
} ?>
</div>
<!-- Pagination -->
<div class="swiper-pagination"></div>
......@@ -29,11 +30,11 @@
</div>
</section>
<section class="container">
<section class="container">
<div class="row gy-4 visual-display-section">
<!-- LEFT CONTENT -->
......@@ -55,35 +56,35 @@
<div class="col-md-6">
<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>
</div>
<div class="col-md-6">
<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>
</div>
<div class="col-md-4">
<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>
</div>
<div class="col-md-4">
<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>
</div>
<div class="col-md-4">
<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>
</div>
......@@ -94,7 +95,7 @@
</section>
<section class="container">
<section class="container">
<div class="achievements-banner" data-aos="zoom-in" data-aos-delay="700">
<div class="row text-center">
<div class="col-lg-3 col-sm-6">
......@@ -142,7 +143,7 @@
<a href="#" class="btn btn-outline-dark">See All</a>
</div>
<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>
......@@ -158,7 +159,7 @@
<a href="#" class="btn btn-outline-light">See All</a>
</div>
<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>
......@@ -174,7 +175,7 @@
<a href="#" class="btn btn-outline-light">See All</a>
</div>
<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>
......@@ -190,7 +191,7 @@
<a href="#" class="btn btn-outline-dark">See All</a>
</div>
<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>
......@@ -199,5 +200,13 @@
</div>
</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
\ No newline at end of file
......@@ -63,6 +63,7 @@
Route::get('products', [ProductController::class, 'products'])->name('products');
Route::get('addProduct/{id?}', [ProductController::class, 'addProduct'])->name('addProduct');
Route::post('storeUpdateproducts', [ProductController::class, 'storeUpdateproducts'])->name('storeUpdateproducts');
Route::post('uploadProducts', [ProductController::class, 'uploadProducts'])->name('uploadProducts');
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