feat: Update uploads files folder in controllers
This commit is contained in:
parent
be698072d0
commit
43fc273663
4 changed files with 28 additions and 28 deletions
|
|
@ -34,11 +34,11 @@ class ContentController extends Controller
|
|||
]);
|
||||
|
||||
if ($banner !== null) {
|
||||
if ($content->banner !== null && file_exists(public_path('images/content/') . $content->banner)) {
|
||||
unlink(public_path('images/content/') . $content->banner);
|
||||
if ($content->banner !== null && file_exists(storage_path('app/public/images/content/') . $content->banner)) {
|
||||
unlink(storage_path('app/public/images/content/') . $content->banner);
|
||||
}
|
||||
$imageName = $content->id . '.' . $banner->extension();
|
||||
$banner->move(public_path('images/content'), $imageName);
|
||||
$banner->move(storage_path('app/public/images/content'), $imageName);
|
||||
$content->banner = $imageName;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,14 +183,14 @@ class ProductsController extends Controller
|
|||
|
||||
if ($picture !== null) {
|
||||
$imageName = $product->id . '_' . $str_random . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/produits'), $imageName);
|
||||
$picture->move(storage_path('app/public/images/produits'), $imageName);
|
||||
$product->picture = $imageName;
|
||||
$product->save();
|
||||
}
|
||||
|
||||
if ($picture_large !== null) {
|
||||
$imageName = $product->id . '_' . $str_random . '_large.' . $picture_large->extension();
|
||||
$picture_large->move(public_path('images/produits'), $imageName);
|
||||
$picture_large->move(storage_path('app/public/images/produits'), $imageName);
|
||||
$product->picture_large = $imageName;
|
||||
$product->save();
|
||||
}
|
||||
|
|
@ -334,24 +334,24 @@ class ProductsController extends Controller
|
|||
if ($picture !== null) {
|
||||
if (
|
||||
$product->picture !== null &&
|
||||
file_exists(public_path('images/produits/') . $product->picture)
|
||||
file_exists(storage_path('app/public/images/produits/') . $product->picture)
|
||||
) {
|
||||
unlink(public_path('images/produits/') . $product->picture);
|
||||
unlink(storage_path('app/public/images/produits/') . $product->picture);
|
||||
}
|
||||
$imageName = $product->id . '_' . $str_random . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/produits'), $imageName);
|
||||
$picture->move(storage_path('app/public/images/produits'), $imageName);
|
||||
$product->picture = $imageName;
|
||||
}
|
||||
|
||||
if ($picture_large !== null) {
|
||||
if (
|
||||
$product->picture_large !== null &&
|
||||
file_exists(public_path('images/produits/') . $product->picture_large)
|
||||
file_exists(storage_path('app/public/images/produits/') . $product->picture_large)
|
||||
) {
|
||||
unlink(public_path('images/produits/') . $product->picture_large);
|
||||
unlink(storage_path('app/public/images/produits/') . $product->picture_large);
|
||||
}
|
||||
$imageName = $product->id . '_' . $str_random . '_large.' . $picture_large->extension();
|
||||
$picture_large->move(public_path('images/produits'), $imageName);
|
||||
$picture_large->move(storage_path('app/public/images/produits'), $imageName);
|
||||
$product->picture_large = $imageName;
|
||||
}
|
||||
}
|
||||
|
|
@ -517,14 +517,14 @@ class ProductsController extends Controller
|
|||
*/
|
||||
public function destroy(Product $product)
|
||||
{
|
||||
if ($product->picture !== null && file_exists(public_path('images/produits/') . $product->picture)) {
|
||||
unlink(public_path('images/produits/') . $product->picture);
|
||||
if ($product->picture !== null && file_exists(storage_path('app/public/images/produits/') . $product->picture)) {
|
||||
unlink(storage_path('app/public/images/produits/') . $product->picture);
|
||||
}
|
||||
if (
|
||||
$product->picture_large !== null &&
|
||||
file_exists(public_path('images/produits/') . $product->picture_large)
|
||||
file_exists(storage_path('app/public/images/produits/') . $product->picture_large)
|
||||
) {
|
||||
unlink(public_path('images/produits/') . $product->picture_large);
|
||||
unlink(storage_path('app/public/images/produits/') . $product->picture_large);
|
||||
}
|
||||
|
||||
OldSlug::where('product_id', $product->id)->delete();
|
||||
|
|
@ -707,7 +707,7 @@ class ProductsController extends Controller
|
|||
// Default is large image.
|
||||
$finalImageName = $product->id . '_' . $str_random . '_large.' . File::extension($imagePath);
|
||||
|
||||
$productimagespath = public_path('images/produits');
|
||||
$productimagespath = storage_path('app/public/images/produits');
|
||||
|
||||
if (!File::isDirectory($productimagespath)) {
|
||||
File::makeDirectory($productimagespath, 0644, true);
|
||||
|
|
@ -718,9 +718,9 @@ class ProductsController extends Controller
|
|||
// Suppression de l'ancien fichier.
|
||||
if (
|
||||
$product->picture_large !== null &&
|
||||
file_exists(public_path('images/produits/') . $product->picture_large)
|
||||
file_exists(storage_path('app/public/images/produits/') . $product->picture_large)
|
||||
) {
|
||||
unlink(public_path('images/produits/') . $product->picture_large);
|
||||
unlink(storage_path('app/public/images/produits/') . $product->picture_large);
|
||||
}
|
||||
|
||||
$product->picture_large = $finalImageName;
|
||||
|
|
@ -732,8 +732,8 @@ class ProductsController extends Controller
|
|||
File::copy($imagePath, $productimagespath . "/" . $finalImageName);
|
||||
|
||||
// Suppression de l'ancien fichier.
|
||||
if ($product->picture !== null && file_exists(public_path('images/produits/') . $product->picture)) {
|
||||
unlink(public_path('images/produits/') . $product->picture);
|
||||
if ($product->picture !== null && file_exists(storage_path('app/public/images/produits/') . $product->picture)) {
|
||||
unlink(storage_path('app/public/images/produits/') . $product->picture);
|
||||
}
|
||||
|
||||
$product->picture = $finalImageName;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class RangesController extends Controller
|
|||
|
||||
if ($picture !== null) {
|
||||
$imageName = $range->id . '_' . $slug . '_' . Str::random(5) . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/gammes'), $imageName);
|
||||
$picture->move(storage_path('app/public/images/gammes'), $imageName);
|
||||
$range->picture = $imageName;
|
||||
$range->save();
|
||||
}
|
||||
|
|
@ -109,11 +109,11 @@ class RangesController extends Controller
|
|||
$range = Range::findOrFail($id);
|
||||
|
||||
if ($picture !== null) {
|
||||
if ($range->picture !== null && file_exists(public_path('images/gammes/') . $range->picture)) {
|
||||
unlink(public_path('images/gammes/') . $range->picture);
|
||||
if ($range->picture !== null && file_exists(storage_path('app/public/images/gammes/') . $range->picture)) {
|
||||
unlink(storage_path('app/public/images/gammes/') . $range->picture);
|
||||
}
|
||||
$imageName = $range->id . '_' . $slug . '_' . Str::random(5) . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/gammes'), $imageName);
|
||||
$picture->move(storage_path('app/public/images/gammes'), $imageName);
|
||||
}
|
||||
|
||||
$range->name = $name;
|
||||
|
|
@ -156,8 +156,8 @@ class RangesController extends Controller
|
|||
}
|
||||
|
||||
if ($range->picture !== null) {
|
||||
if (file_exists(public_path('images/gammes/') . $range->picture)) {
|
||||
unlink(public_path('images/gammes/') . $range->picture);
|
||||
if (file_exists(storage_path('app/public/images/gammes/') . $range->picture)) {
|
||||
unlink(storage_path('app/public/images/gammes/') . $range->picture);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class SlidesController extends Controller
|
|||
|
||||
if ($picture !== null) {
|
||||
$imageName = $slide->id . '_' . Str::random(5) . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/slides'), $imageName);
|
||||
$picture->move(storage_path('app/public/images/slides'), $imageName);
|
||||
$slide->picture = $imageName;
|
||||
$slide->save();
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ class SlidesController extends Controller
|
|||
unlink(public_path() . 'images/slides/' . $slide->picture);
|
||||
}
|
||||
$imageName = $slide->id . '_' . Str::random(5) . '.' . $picture->extension();
|
||||
$picture->move(public_path('images/slides'), $imageName);
|
||||
$picture->move(storage_path('app/public/images/slides'), $imageName);
|
||||
$slide->picture = $imageName;
|
||||
$slide->save();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue