Commit d448e525 by Hussain Mohamed

changes

parent 18303e5d
...@@ -37,7 +37,12 @@ public function addProduct($id = '') ...@@ -37,7 +37,12 @@ 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();
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 { } else {
return view('backend.products.add', compact('categoryData', 'sizeData', 'typeData', 'brandData', 'industryData')); return view('backend.products.add', compact('categoryData', 'sizeData', 'typeData', 'brandData', 'industryData'));
} }
...@@ -72,47 +77,47 @@ public function storeUpdateproducts(Request $request) ...@@ -72,47 +77,47 @@ public function storeUpdateproducts(Request $request)
'product_description' => $product_description, 'product_description' => $product_description,
); );
if (($request->hasFile('broucher'))) { if ($request->hasFile('broucher')) {
$broucher = $request->file('broucher'); $broucher = $request->file('broucher');
$broucherName = 'broucher' . time() . '_' . str_replace(' ', '_', $broucher->getClientOriginalName()); $broucherName = 'broucher' . time() . '_' . str_replace(' ', '_', $broucher->getClientOriginalName());
$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;
$insertAr['broucher'] = $broucherUrl; $insertArr['broucher'] = $broucherUrl;
} }
$insert = ProductModel::create($insertArr); $insert = ProductModel::create($insertArr);
if ($insert['id'] > 0) { if ($insert['id'] > 0) {
foreach ($category_id as $val) { foreach ($category_id as $val) {
$insertAr = array( $cateAr = array(
'product_id' => $insert['id'], 'product_id' => $insert['id'],
'category_id' => $val 'category_id' => $val
); );
CategoryProduct::create($insertAr); CategoryProduct::create($cateAr);
} }
foreach ($industry_id as $val) { foreach ($industry_id as $val) {
$insertAr = array( $indusarr = array(
'product_id' => $insert['id'], 'product_id' => $insert['id'],
'industry_id' => $val 'industry_id' => $val
); );
IndustryProduct::create($insertAr); IndustryProduct::create($indusarr);
} }
foreach ($brand_id as $val) { foreach ($brand_id as $val) {
$insertAr = array( $brandarr = array(
'product_id' => $insert['id'], 'product_id' => $insert['id'],
'brand_id' => $val 'brand_id' => $val
); );
BrandProduct::create($insertAr); BrandProduct::create($brandarr);
} }
foreach ($product_size as $val) { foreach ($product_size as $val) {
$insertAr = array( $sizearr = array(
'product_id' => $insert['id'], 'product_id' => $insert['id'],
'size_id' => $val 'size_id' => $val
); );
SizeProduct::create($insertAr); SizeProduct::create($sizearr);
} }
foreach ($request->file('product_image') as $k => $image) { foreach ($request->file('product_image') as $k => $image) {
...@@ -137,12 +142,13 @@ public function storeUpdateproducts(Request $request) ...@@ -137,12 +142,13 @@ public function storeUpdateproducts(Request $request)
'size_type' => $size_type, 'size_type' => $size_type,
'product_description' => $product_description, 'product_description' => $product_description,
); );
if (($request->hasFile('broucher'))) { if ($request->hasFile('broucher') != '') {
$broucher = $request->file('broucher'); $broucher = $request->file('broucher');
$broucherName = 'broucher' . time() . '_' . str_replace(' ', '_', $broucher->getClientOriginalName()); $broucherName = 'broucher' . time() . '_' . str_replace(' ', '_', $broucher->getClientOriginalName());
$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;
$insertAr['broucher'] = $broucherUrl; $insertArr['broucher'] = $broucherUrl;
} }
$update = ProductModel::Where('id', $id)->update($insertArr); $update = ProductModel::Where('id', $id)->update($insertArr);
...@@ -151,37 +157,37 @@ public function storeUpdateproducts(Request $request) ...@@ -151,37 +157,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) {
$insertAr = array( $cateAr = array(
'product_id' => $id, 'product_id' => $id,
'category_id' => $val 'category_id' => $val
); );
CategoryProduct::create($insertAr); CategoryProduct::create($cateAr);
} }
foreach ($industry_id as $val) { foreach ($industry_id as $val) {
$insertAr = array( $indusarr = array(
'product_id' => $id, 'product_id' => $id,
'industry_id' => $val 'industry_id' => $val
); );
IndustryProduct::create($insertAr); IndustryProduct::create($indusarr);
} }
foreach ($brand_id as $val) { foreach ($brand_id as $val) {
$insertAr = array( $brandarr = array(
'product_id' => $id, 'product_id' => $id,
'brand_id' => $val 'brand_id' => $val
); );
BrandProduct::create($insertAr); BrandProduct::create($brandarr);
} }
foreach ($product_size as $val) { foreach ($product_size as $val) {
$insertAr = array( $sizearr = array(
'product_id' => $id, 'product_id' => $id,
'size_id' => $val 'size_id' => $val
); );
SizeProduct::create($insertAr); SizeProduct::create($sizearr);
} }
foreach ($item_id as $k => $val) { foreach ($item_id as $k => $val) {
if ($val == '' || $val == 0) { if ($val == '' || $val == 0) {
......
...@@ -316,10 +316,7 @@ ...@@ -316,10 +316,7 @@
<li class="slide pe-nav-content1"> <li class="slide pe-nav-content1">
<a href="javascript:void(0)">Pages</a> <a href="javascript:void(0)">Pages</a>
</li> </li>
<li class="pe-slide-item"> <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"> <a href="<?= url('backend/addPage/1') ?>" class="pe-nav-link">
Terms & Condition Terms & Condition
</a> </a>
...@@ -334,7 +331,7 @@ ...@@ -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"> <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> <i class="bi bi-files pe-nav-icon"></i>
<span class="pe-nav-content">SEO Settings</span> <span class="pe-nav-content">SEO Settings</span>
...@@ -350,15 +347,15 @@ ...@@ -350,15 +347,15 @@
</a> </a>
</li> </li>
</ul> </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"> <a href="<?= route('settings') ?>" class="pe-nav-link">
<i class="bi bi bi-gear-fill pe-nav-icon"></i> <i class="bi bi bi-gear-fill pe-nav-icon"></i>
<span class="pe-nav-setting">Settings</span> <span class="pe-nav-setting">Settings</span>
</a> </a>
</li> </li> -->
......
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
@section('content') @section('content')
<?php <?php
$id = isset($record->id) ? $record->id : ''; $id = isset($record->id) ? $record->id : '';
$category_id = isset($record->category_id) ? $record->category_id : ''; $size_type = isset($record->size_type) ? $record->size_type : '';
$brand_id = isset($record->brand_id) ? $record->brand_id : ''; $broucher = isset($record->broucher) ? $record->broucher : '';
$industry_id = isset($record->industry_id) ? $record->industry_id : '';
$type_id = isset($record->type_id) ? $record->type_id : ''; $type_id = isset($record->type_id) ? $record->type_id : '';
$product_name = isset($record->product_name) ? $record->product_name : ''; $product_name = isset($record->product_name) ? $record->product_name : '';
$product_description = isset($record->product_description) ? $record->product_description : ''; $product_description = isset($record->product_description) ? $record->product_description : '';
...@@ -55,7 +54,7 @@ ...@@ -55,7 +54,7 @@
<?php <?php
if (isset($categoryData)) { if (isset($categoryData)) {
foreach ($categoryData as $val) {?> 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 } <?php }
}?> }?>
</select> </select>
...@@ -69,7 +68,7 @@ ...@@ -69,7 +68,7 @@
<?php <?php
if (isset($industryData)) { if (isset($industryData)) {
foreach ($industryData as $val) {?> 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 } <?php }
}?> }?>
</select> </select>
...@@ -84,7 +83,7 @@ ...@@ -84,7 +83,7 @@
<?php <?php
if (isset($brandData)) { if (isset($brandData)) {
foreach ($brandData as $val) {?> 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 } <?php }
}?> }?>
</select> </select>
...@@ -110,12 +109,12 @@ ...@@ -110,12 +109,12 @@
<label for="type_id" class="form-label">Size Type<span class="text-danger"> *</span></label> <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"> <select class="form-control select2" id="size_type" name="size_type">
<option value="">--select--</option> <option value="">--select--</option>
<option value="1">Size</option> <option <?= ($size_type == 1) ? 'selected':'' ?> value="1">Size</option>
<option value="2">Range</option> <option <?= ($size_type == 2) ? 'selected':'' ?> value="2">Range</option>
<option value="3">Capacity</option> <option <?= ($size_type == 3) ? 'selected':'' ?> value="3">Capacity</option>
</select> </select>
</div> </div>
<div class="col-xl-4"> <div class="col-xl-4">
<label for="type_id" class="form-label">Product Size<span class="text-danger"> *</span></label> <label for="type_id" class="form-label">Product Size<span class="text-danger"> *</span></label>
<select class="form-control select2" id="size" multiple name="size[]"> <select class="form-control select2" id="size" multiple name="size[]">
...@@ -123,7 +122,7 @@ ...@@ -123,7 +122,7 @@
<?php <?php
if (isset($sizeData)) { if (isset($sizeData)) {
foreach ($sizeData as $val) { ?> 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 } <?php }
} ?> } ?>
</select> </select>
...@@ -133,6 +132,12 @@ ...@@ -133,6 +132,12 @@
<label for="type_id" class="form-label">Product Catalogue<span class="text-danger"> *</span></label> <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"> <input type="file" name="broucher" id="broucher" class="form-control">
</div> </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"> <div class="col-xl-12">
<label for="type_id" class="form-label">Product Description</label> <label for="type_id" class="form-label">Product Description</label>
...@@ -142,6 +147,7 @@ ...@@ -142,6 +147,7 @@
<table style="width:100%" class="table"> <table style="width:100%" class="table">
<tr> <tr>
<th>Image</th> <th>Image</th>
<th>Exist Image</th>
<!--<th>Catalogue</th> <!--<th>Catalogue</th>
<th>Product Type</th> <th>Product Type</th>
<th>Product Size</th> --> <th>Product Size</th> -->
...@@ -155,6 +161,9 @@ ...@@ -155,6 +161,9 @@
<td style="width:20%"> <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"> <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>
<td style="width:20%">
<img src="<?= $row->product_image ?>" width="100" height="100"/>
</td>
<!--<td style="width:20%"> <!--<td style="width:20%">
<input data-row="<?= $key ?>" data-name="broucher" id="broucher<?= $key ?>" type="file" name="broucher[]" id="broucher" class="form-control"> <input data-row="<?= $key ?>" data-name="broucher" id="broucher<?= $key ?>" type="file" name="broucher[]" id="broucher" class="form-control">
</td> </td>
...@@ -214,7 +223,7 @@ function addRow(content_id, label_checkbox = '') { ...@@ -214,7 +223,7 @@ function addRow(content_id, label_checkbox = '') {
row.find("select").each(function(index) { row.find("select").each(function(index) {
$(this).select2('destroy'); $(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; i = $(this).data('row') + 1;
id = $(this).data('name') + i; id = $(this).data('name') + i;
$(this).val('').attr({ $(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