Skip to content

Commit

Permalink
photo edit on products
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciframa committed Dec 24, 2024
1 parent 923bda5 commit a790133
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Fitmo_backend/app/Http/Controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -987,13 +987,13 @@ public function update(Request $request, $id)
foreach ($request->photos as $photo) {
if ($photo["state"] === 'added') {
$folderPath = 'products/';
if (isset($child->color_id)) {
$existingColor = Color::find($child->color_id);
$folderPath .= $child->name . "-" . $existingColor->color_name;
} elseif (isset($child->variant)) {
$folderPath .= $child->name . "-" . $child->variant;
if (isset($product->color_id)) {
$existingColor = Color::find($product->color_id);
$folderPath .= $product->name . "-" . $existingColor->color_name;
} elseif (isset($product->variant)) {
$folderPath .= $product->name . "-" . $product->variant;
} else {
$folderPath .= $child->name;
$folderPath .= $product->name;
}
if (File::exists($folderPath) && File::isDirectory($folderPath)) {
$newImg = new Image();
Expand Down Expand Up @@ -1022,13 +1022,13 @@ public function update(Request $request, $id)
->first();
$existingImage->delete();
$folderPath = 'products/';
if (isset($child->color_id)) {
$existingColor = Color::find($child->color_id);
$folderPath .= $child->name . "-" . $existingColor->color_name;
} elseif (isset($child->variant)) {
$folderPath .= $child->name . "-" . $child->variant;
if (isset($product->color_id)) {
$existingColor = Color::find($product->color_id);
$folderPath .= $product->name . "-" . $existingColor->color_name;
} elseif (isset($product->variant)) {
$folderPath .= $product->name . "-" . $product->variant;
} else {
$folderPath .= $child->name;
$folderPath .= $product->name;
}
if (File::exists($folderPath) && File::isDirectory($folderPath)) {
$imageFiles = glob($folderPath . '/*.jpg');
Expand Down

0 comments on commit a790133

Please sign in to comment.