Commit d448e525 by Hussain Mohamed

changes

parent 18303e5d
......@@ -37,7 +37,12 @@ public function addProduct($id = '')
if ($id > 0) {
$record = ProductModel::Where('id', $id)->first();
$productItems = ProductAttributeModel::Where('product_id', $id)->get();
return view('backend.products.edit', compact('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'));
}
......@@ -72,47 +77,47 @@ public function storeUpdateproducts(Request $request)
'product_description' => $product_description,
);
if (($request->hasFile('broucher'))) {
if ($request->hasFile('broucher')) {
$broucher = $request->file('broucher');
$broucherName = 'broucher' . time() . '_' . str_replace(' ', '_', $broucher->getClientOriginalName());
$broucher->move(public_path('/uploads/broucher/'), $broucherName);
$broucherUrl = URL::to('/') . '/uploads/broucher/' . $broucherName;
$insertAr['broucher'] = $broucherUrl;
$insertArr['broucher'] = $broucherUrl;
}
$insert = ProductModel::create($insertArr);
if ($insert['id'] > 0) {
foreach ($category_id as $val) {
$insertAr = array(
$cateAr = array(
'product_id' => $insert['id'],
'category_id' => $val
);
CategoryProduct::create($insertAr);
CategoryProduct::create($cateAr);
}
foreach ($industry_id as $val) {
$insertAr = array(
$indusarr = array(
'product_id' => $insert['id'],
'industry_id' => $val
);
IndustryProduct::create($insertAr);
IndustryProduct::create($indusarr);
}
foreach ($brand_id as $val) {
$insertAr = array(
$brandarr = array(
'product_id' => $insert['id'],
'brand_id' => $val
);
BrandProduct::create($insertAr);
BrandProduct::create($brandarr);
}
foreach ($product_size as $val) {
$insertAr = array(
$sizearr = array(
'product_id' => $insert['id'],
'size_id' => $val
);
SizeProduct::create($insertAr);
SizeProduct::create($sizearr);
}
foreach ($request->file('product_image') as $k => $image) {
......@@ -137,12 +142,13 @@ public function storeUpdateproducts(Request $request)
'size_type' => $size_type,
'product_description' => $product_description,
);
if (($request->hasFile('broucher'))) {
if ($request->hasFile('broucher') != '') {
$broucher = $request->file('broucher');
$broucherName = 'broucher' . time() . '_' . str_replace(' ', '_', $broucher->getClientOriginalName());
$broucher->move(public_path('/uploads/broucher/'), $broucherName);
$broucherUrl = URL::to('/') . '/uploads/broucher/' . $broucherName;
$insertAr['broucher'] = $broucherUrl;
$insertArr['broucher'] = $broucherUrl;
}
$update = ProductModel::Where('id', $id)->update($insertArr);
......@@ -152,35 +158,35 @@ public function storeUpdateproducts(Request $request)
SizeProduct::Where('product_id', $id)->delete();
foreach ($category_id as $val) {
$insertAr = array(
$cateAr = array(
'product_id' => $id,
'category_id' => $val
);
CategoryProduct::create($insertAr);
CategoryProduct::create($cateAr);
}
foreach ($industry_id as $val) {
$insertAr = array(
$indusarr = array(
'product_id' => $id,
'industry_id' => $val
);
IndustryProduct::create($insertAr);
IndustryProduct::create($indusarr);
}
foreach ($brand_id as $val) {
$insertAr = array(
$brandarr = array(
'product_id' => $id,
'brand_id' => $val
);
BrandProduct::create($insertAr);
BrandProduct::create($brandarr);
}
foreach ($product_size as $val) {
$insertAr = array(
$sizearr = array(
'product_id' => $id,
'size_id' => $val
);
SizeProduct::create($insertAr);
SizeProduct::create($sizearr);
}
foreach ($item_id as $k => $val) {
......
......@@ -317,9 +317,6 @@
<a href="javascript:void(0)">Pages</a>
</li>
<li class="pe-slide-item">
<a href="<?= route('pages') ?>" class="pe-nav-link">
Pages
</a>
<a href="<?= url('backend/addPage/1') ?>" class="pe-nav-link">
Terms & Condition
</a>
......@@ -334,7 +331,7 @@
<li class="pe-slide pe-has-sub">
<!-- <li class="pe-slide pe-has-sub">
<a href="#collapseLogistics4" class="pe-nav-link" data-bs-toggle="collapse" aria-expanded="false" aria-controls="collapseLogistics">
<i class="bi bi-files pe-nav-icon"></i>
<span class="pe-nav-content">SEO Settings</span>
......@@ -350,15 +347,15 @@
</a>
</li>
</ul>
</li>
</li> -->
<li class="pe-slide pe-has-sub">
<!-- <li class="pe-slide pe-has-sub">
<a href="<?= route('settings') ?>" class="pe-nav-link">
<i class="bi bi bi-gear-fill pe-nav-icon"></i>
<span class="pe-nav-setting">Settings</span>
</a>
</li>
</li> -->
......
......@@ -3,9 +3,8 @@
@section('content')
<?php
$id = isset($record->id) ? $record->id : '';
$category_id = isset($record->category_id) ? $record->category_id : '';
$brand_id = isset($record->brand_id) ? $record->brand_id : '';
$industry_id = isset($record->industry_id) ? $record->industry_id : '';
$size_type = isset($record->size_type) ? $record->size_type : '';
$broucher = isset($record->broucher) ? $record->broucher : '';
$type_id = isset($record->type_id) ? $record->type_id : '';
$product_name = isset($record->product_name) ? $record->product_name : '';
$product_description = isset($record->product_description) ? $record->product_description : '';
......@@ -55,7 +54,7 @@
<?php
if (isset($categoryData)) {
foreach ($categoryData as $val) {?>
<option value="<?php echo $val->id ?>" <?= ($category_id == $val->id) ? 'selected':'' ?> ><?php echo ucwords($val->category_name) ?></option>
<option value="<?php echo $val->id ?>" <?= in_array($val->id,$categoryAr) ? 'selected':'' ?> ><?php echo ucwords($val->category_name) ?></option>
<?php }
}?>
</select>
......@@ -69,7 +68,7 @@
<?php
if (isset($industryData)) {
foreach ($industryData as $val) {?>
<option <?= in_array($val->id,explode(",",$industry_id)) ? 'selected':'' ?> value="<?php echo $val->id ?>"><?php echo ucwords($val->industry) ?></option>
<option <?= in_array($val->id,$indusAr) ? 'selected':'' ?> value="<?php echo $val->id ?>"><?php echo ucwords($val->industry) ?></option>
<?php }
}?>
</select>
......@@ -84,7 +83,7 @@
<?php
if (isset($brandData)) {
foreach ($brandData as $val) {?>
<option <?= in_array($val->id,explode(",",$brand_id)) ? 'selected':'' ?> value="<?php echo $val->id ?>"><?php echo ucwords($val->brand) ?></option>
<option <?= in_array($val->id,$brandAr) ? 'selected':'' ?> value="<?php echo $val->id ?>"><?php echo ucwords($val->brand) ?></option>
<?php }
}?>
</select>
......@@ -110,9 +109,9 @@
<label for="type_id" class="form-label">Size Type<span class="text-danger"> *</span></label>
<select class="form-control select2" id="size_type" name="size_type">
<option value="">--select--</option>
<option value="1">Size</option>
<option value="2">Range</option>
<option value="3">Capacity</option>
<option <?= ($size_type == 1) ? 'selected':'' ?> value="1">Size</option>
<option <?= ($size_type == 2) ? 'selected':'' ?> value="2">Range</option>
<option <?= ($size_type == 3) ? 'selected':'' ?> value="3">Capacity</option>
</select>
</div>
......@@ -123,7 +122,7 @@
<?php
if (isset($sizeData)) {
foreach ($sizeData as $val) { ?>
<option value="<?php echo $val->id ?>"><?php echo ucwords($val->size) ?></option>
<option <?= in_array($val->id,$sizeAr) ? 'selected':'' ?> value="<?php echo $val->id ?>"><?php echo ucwords($val->size) ?></option>
<?php }
} ?>
</select>
......@@ -133,6 +132,12 @@
<label for="type_id" class="form-label">Product Catalogue<span class="text-danger"> *</span></label>
<input type="file" name="broucher" id="broucher" class="form-control">
</div>
<?php if($broucher != ''){ ?>
<div class="col-xl-4">
<label for="type_id" class="form-label">Product Catalogue</label>
<iframe src="<?= $broucher ?>"></iframe>
</div>
<?php } ?>
<div class="col-xl-12">
<label for="type_id" class="form-label">Product Description</label>
......@@ -142,6 +147,7 @@
<table style="width:100%" class="table">
<tr>
<th>Image</th>
<th>Exist Image</th>
<!--<th>Catalogue</th>
<th>Product Type</th>
<th>Product Size</th> -->
......@@ -155,6 +161,9 @@
<td style="width:20%">
<input data-row="<?= $key ?>" data-name="product_image" id="product_image<?= $key ?>" type="file" name="product_image[]" id="product_image" class="form-control">
</td>
<td style="width:20%">
<img src="<?= $row->product_image ?>" width="100" height="100"/>
</td>
<!--<td style="width:20%">
<input data-row="<?= $key ?>" data-name="broucher" id="broucher<?= $key ?>" type="file" name="broucher[]" id="broucher" class="form-control">
</td>
......@@ -214,7 +223,7 @@ function addRow(content_id, label_checkbox = '') {
row.find("select").each(function(index) {
$(this).select2('destroy');
});
row.clone().find("input, textarea, select, button, checkbox, radio, label").each(function(j, obj) {
row.clone().find("img").remove().end().find("input, textarea, select, button, checkbox, radio, label").each(function(j, obj) {
i = $(this).data('row') + 1;
id = $(this).data('name') + i;
$(this).val('').attr({
......
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