Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
palaniapp_demo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hussain Mohamed
palaniapp_demo
Commits
18303e5d
Commit
18303e5d
authored
Dec 24, 2025
by
Hussain Mohamed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
product changes
parent
097dd9b9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
127 additions
and
61 deletions
+127
-61
ProductController.php
app/Http/Controllers/Backend/ProductController.php
+122
-61
BrandProduct.php
app/Models/BrandProduct.php
+1
-0
CategoryProduct.php
app/Models/CategoryProduct.php
+1
-0
IndustryProduct.php
app/Models/IndustryProduct.php
+1
-0
SizeModel.php
app/Models/SizeModel.php
+1
-0
SizeProduct.php
app/Models/SizeProduct.php
+1
-0
No files found.
app/Http/Controllers/Backend/ProductController.php
View file @
18303e5d
...
...
@@ -3,13 +3,17 @@
namespace
App\Http\Controllers\Backend
;
use
App\Http\Controllers\Controller
;
use
App\Models\BrandProduct
;
use
App\Models\CategoryModel
;
use
App\Models\CategoryProduct
;
use
App\Models\IndustryProduct
;
use
App\Models\ProductAttributeModel
;
use
App\Models\ProductBrandModel
;
use
App\Models\ProductIndustryModel
;
use
App\Models\ProductModel
;
use
App\Models\ProductTypeModel
;
use
App\Models\SizeModel
;
use
App\Models\SizeProduct
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\URL
;
...
...
@@ -17,8 +21,8 @@ class ProductController extends Controller
{
public
function
products
()
{
// $records = ProductModel::with('category')->get();
$records
=
ProductModel
::
orderBy
(
'id'
,
'ASC'
)
->
get
();
// $records = ProductModel::with('category')->get();
$records
=
ProductModel
::
orderBy
(
'id'
,
'ASC'
)
->
get
();
// dd($records);
return
view
(
'backend.products.list'
,
compact
(
'records'
));
}
...
...
@@ -49,7 +53,7 @@ public function storeUpdateproducts(Request $request)
$brand_id
=
isset
(
$input
[
'brand_id'
])
?
$input
[
'brand_id'
]
:
''
;
$type_id
=
isset
(
$input
[
'type_id'
])
?
$input
[
'type_id'
]
:
''
;
$product_description
=
isset
(
$input
[
'product_description'
])
?
$input
[
'product_description'
]
:
''
;
$
product
_type
=
isset
(
$input
[
'size_type'
])
?
$input
[
'size_type'
]
:
''
;
$
size
_type
=
isset
(
$input
[
'size_type'
])
?
$input
[
'size_type'
]
:
''
;
$product_size
=
isset
(
$input
[
'size'
])
?
$input
[
'size'
]
:
''
;
$item_id
=
isset
(
$input
[
'item_id'
])
?
$input
[
'item_id'
]
:
''
;
$product_image
=
isset
(
$input
[
'product_image'
])
?
$input
[
'product_image'
]
:
''
;
...
...
@@ -60,21 +64,60 @@ public function storeUpdateproducts(Request $request)
/* Insert */
$insertArr
=
array
(
'product_name'
=>
$product_name
,
'category_id'
=>
implode
(
","
,
$category_id
),
'industry_id'
=>
implode
(
","
,
$industry_id
),
'brand_id'
=>
implode
(
","
,
$brand_id
),
//
'category_id' => implode(",", $category_id),
//
'industry_id' => implode(",", $industry_id),
//
'brand_id' => implode(",", $brand_id),
'type_id'
=>
$type_id
,
'size_type'
=>
$size_type
,
'product_description'
=>
$product_description
,
);
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
;
}
$insert
=
ProductModel
::
create
(
$insertArr
);
if
(
$insert
[
'id'
]
>
0
)
{
foreach
(
$product_size
as
$k
=>
$val
)
{
$insertAr
=
array
(
'product_type'
=>
$product_type
[
$k
],
'product_size'
=>
$product_size
[
$k
]
foreach
(
$category_id
as
$val
)
{
$insertAr
=
array
(
'product_id'
=>
$insert
[
'id'
],
'category_id'
=>
$val
);
CategoryProduct
::
create
(
$insertAr
);
}
foreach
(
$industry_id
as
$val
)
{
$insertAr
=
array
(
'product_id'
=>
$insert
[
'id'
],
'industry_id'
=>
$val
);
IndustryProduct
::
create
(
$insertAr
);
}
foreach
(
$brand_id
as
$val
)
{
$insertAr
=
array
(
'product_id'
=>
$insert
[
'id'
],
'brand_id'
=>
$val
);
BrandProduct
::
create
(
$insertAr
);
}
foreach
(
$product_size
as
$val
)
{
$insertAr
=
array
(
'product_id'
=>
$insert
[
'id'
],
'size_id'
=>
$val
);
SizeProduct
::
create
(
$insertAr
);
}
foreach
(
$request
->
file
(
'product_image'
)
as
$k
=>
$image
)
{
$insertAr
=
array
(
'product_id'
=>
$insert
[
'id'
],
);
if
(
isset
(
$request
->
file
(
'product_image'
)[
$k
]))
{
$image
=
$request
->
file
(
'product_image'
)[
$k
];
...
...
@@ -83,71 +126,89 @@ public function storeUpdateproducts(Request $request)
$imageUrl
=
URL
::
to
(
'/'
)
.
'/uploads/product_image/'
.
$imageName
;
$insertAr
[
'product_image'
]
=
$imageUrl
;
}
if
(
isset
(
$request
->
file
(
'broucher'
)[
$k
]))
{
$broucher
=
$request
->
file
(
'broucher'
)[
$k
];
$broucherName
=
'broucher'
.
time
()
.
'_'
.
str_replace
(
' '
,
'_'
,
$broucher
->
getClientOriginalName
());
$broucher
->
move
(
public_path
(
'/uploads/broucher/'
),
$broucherName
);
$broucherUrl
=
URL
::
to
(
'/'
)
.
'/uploads/broucher/'
.
$broucherName
;
$insertAr
[
'broucher'
]
=
$broucherUrl
;
}
ProductAttributeModel
::
create
(
$insertAr
);
}
}
return
redirect
()
->
route
(
'products'
)
->
with
(
'success'
,
'Pages Saved Successfully'
);
}
}
else
{
$insertArr
=
array
(
'product_name'
=>
$product_name
,
'category_id'
=>
implode
(
","
,
$category_id
),
'industry_id'
=>
implode
(
","
,
$industry_id
),
'brand_id'
=>
implode
(
","
,
$brand_id
),
'type_id'
=>
$type_id
,
'type_id'
=>
$type_id
,
'size_type'
=>
$size_type
,
'product_description'
=>
$product_description
,
);
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
;
}
$update
=
ProductModel
::
Where
(
'id'
,
$id
)
->
update
(
$insertArr
);
CategoryProduct
::
Where
(
'product_id'
,
$id
)
->
delete
();
IndustryProduct
::
Where
(
'product_id'
,
$id
)
->
delete
();
BrandProduct
::
Where
(
'product_id'
,
$id
)
->
delete
();
SizeProduct
::
Where
(
'product_id'
,
$id
)
->
delete
();
foreach
(
$category_id
as
$val
)
{
$insertAr
=
array
(
'product_id'
=>
$id
,
'category_id'
=>
$val
);
CategoryProduct
::
create
(
$insertAr
);
}
foreach
(
$industry_id
as
$val
)
{
$insertAr
=
array
(
'product_id'
=>
$id
,
'industry_id'
=>
$val
);
IndustryProduct
::
create
(
$insertAr
);
}
foreach
(
$brand_id
as
$val
)
{
$insertAr
=
array
(
'product_id'
=>
$id
,
'brand_id'
=>
$val
);
BrandProduct
::
create
(
$insertAr
);
}
foreach
(
$product_size
as
$val
)
{
$insertAr
=
array
(
'product_id'
=>
$id
,
'size_id'
=>
$val
);
SizeProduct
::
create
(
$insertAr
);
}
foreach
(
$item_id
as
$k
=>
$val
)
{
if
(
$val
==
''
||
$val
==
0
)
{
/** if id is not new list will insert */
$insertAr
=
array
(
'product_type'
=>
$product_type
[
$k
],
'product_size'
=>
$product_size
[
$k
]
);
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
;
$insertAr
[
'product_image'
]
=
$imageUrl
;
}
if
(
isset
(
$request
->
file
(
'broucher'
)[
$k
]))
{
$broucher
=
$request
->
file
(
'broucher'
)[
$k
];
$broucherName
=
'broucher'
.
time
()
.
'_'
.
str_replace
(
' '
,
'_'
,
$broucher
->
getClientOriginalName
());
$broucher
->
move
(
public_path
(
'/uploads/broucher/'
),
$broucherName
);
$broucherUrl
=
URL
::
to
(
'/'
)
.
'/uploads/broucher/'
.
$broucherName
;
$insertAr
[
'broucher'
]
=
$broucherUrl
;
foreach
(
$request
->
file
(
'product_image'
)
as
$k
=>
$image
)
{
$insertA
=
array
(
'product_id'
=>
$id
,
);
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
;
$insertA
[
'product_image'
]
=
$imageUrl
;
}
ProductAttributeModel
::
create
(
$insertA
);
}
ProductAttributeModel
::
create
(
$insertAr
);
}
else
{
/** if id is available new list will update */
$insertAr
=
array
(
'product_type'
=>
$product_type
[
$k
],
'product_size'
=>
$product_size
[
$k
]
);
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
;
$insertAr
[
'product_image'
]
=
$imageUrl
;
}
if
(
isset
(
$request
->
file
(
'broucher'
)[
$k
]))
{
$broucher
=
$request
->
file
(
'broucher'
)[
$k
];
$broucherName
=
'broucher'
.
time
()
.
'_'
.
str_replace
(
' '
,
'_'
,
$broucher
->
getClientOriginalName
());
$broucher
->
move
(
public_path
(
'/uploads/broucher/'
),
$broucherName
);
$broucherUrl
=
URL
::
to
(
'/'
)
.
'/uploads/broucher/'
.
$broucherName
;
$insertAr
[
'broucher'
]
=
$broucherUrl
;
}
ProductAttributeModel
::
Where
(
'product_id'
,
$id
)
->
Where
(
'id'
,
$val
)
->
update
(
$insertAr
);
/** 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'
);
...
...
app/Models/BrandProduct.php
View file @
18303e5d
...
...
@@ -10,4 +10,5 @@ class BrandProduct extends Model
use
HasFactory
;
protected
$table
=
'product_brand'
;
protected
$guarded
=
[
'id'
];
public
$timestamps
=
false
;
}
app/Models/CategoryProduct.php
View file @
18303e5d
...
...
@@ -10,4 +10,5 @@ class CategoryProduct extends Model
use
HasFactory
;
protected
$table
=
'product_category'
;
protected
$guarded
=
[
'id'
];
public
$timestamps
=
false
;
}
app/Models/IndustryProduct.php
View file @
18303e5d
...
...
@@ -10,4 +10,5 @@ class IndustryProduct extends Model
use
HasFactory
;
protected
$table
=
'product_industry'
;
protected
$guarded
=
[
'id'
];
public
$timestamps
=
false
;
}
app/Models/SizeModel.php
View file @
18303e5d
...
...
@@ -10,4 +10,5 @@ class SizeModel extends Model
use
HasFactory
;
protected
$table
=
'size'
;
protected
$guarded
=
[
'id'
];
}
app/Models/SizeProduct.php
View file @
18303e5d
...
...
@@ -10,4 +10,5 @@ class SizeProduct extends Model
use
HasFactory
;
protected
$table
=
'product_size'
;
protected
$guarded
=
[
'id'
];
public
$timestamps
=
false
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment