extension(); $name = time() . '.' . $file->getClientOriginalExtension(); $originalImageName = $type . '_' . $id . '_' . $sub_id . '_' . $name ; //if image already exist unlink that image $path = public_path() . '/uploads/' . $type . '/' . $originalImageName; // if(File::exists($path)) { // unlink($path); // } $file->storeAs($actualImagePath, $originalImageName, 'public'); $sub_id++; $imagePath[] = $originalImageName; } return $imagePath; } } /** * Created By : Pradyumn Dwivedi * Created at : 06 November 2023 * Use : To upload single image without crop */ if (!function_exists('saveSingleImageWithoutCrop')) { function saveSingleImageWithoutCrop($image, $path, $image_db = null) { $thumbnail = ''; if (!empty($image)) { // Define the folder path where the image will be stored $folderPath = storage_path('app/public/uploads/' . $path . '/'); // Generate a unique image name $imageName = uniqid() . '.png'; // Move the uploaded image to the specified folder $image->move($folderPath, $imageName); // If there was a previous image, delete it if (!empty($image_db)) { $previousImagePath = $folderPath . $image_db; if (file_exists($previousImagePath)) { unlink($previousImagePath); } } $thumbnail = $imageName; } elseif (!empty($image_db)) { $thumbnail = $image_db; } return $thumbnail; } } /** * Created By : Pradyumn Dwivedi * Created at : 06 November 2023 * Use : Function for listing image url */ if (!function_exists('VendorListingIconUrl')) { function VendorListingIconUrl($type, $imageName) { $src = ''; $defaultImagePath = ""; if (!empty($imageName) && file_exists('public/vendor/' . $type . '/' . $imageName)) { $src = 'public/vendor/' . $type . '/' . $imageName . '?d=' . time(); } else { $src = "public/admin/assets/media/wedzy/default_img.jpg?d=" . time(); } return url($src); } } /** * Created By : Chandan Yadav * Created at : 12 Jan 2024 * Use : Function for listing image url */ if (!function_exists('DuoListingIconUrl')) { function DuoListingIconUrl($type, $imageName) { $src = ''; $defaultImagePath = ""; if (!empty($imageName) && file_exists('public/duo/' . $type . '/' . $imageName)) { $src = 'public/duo/' . $type . '/' . $imageName . '?d=' . time(); } else { $src = "public/admin/assets/media/wedzy/default_img.jpg?d=" . time(); } return url($src); } }