diff --git a/app/Lib/Helpers/FileStorageHelper.php b/app/Lib/Helpers/FileStorageHelper.php index 0e691d6..08a9f8c 100644 --- a/app/Lib/Helpers/FileStorageHelper.php +++ b/app/Lib/Helpers/FileStorageHelper.php @@ -30,6 +30,20 @@ use Illuminate\Support\Str; */ class FileStorageHelper { + /** + * Remove all files from string attribute html that are stored in public + * + * @param string $publicStorageFilePath The file path from public directory. + * @return string The local storage path. + */ + public static function getFileFullPath(string $publicStorageFilePath): string + { + /** @var \Illuminate\Filesystem\FilesystemAdapter */ + $disk = Storage::disk('uploads'); + $path = ToolboxHelper::mbReplace('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/')); + return $disk->path($path); + } + /** * Destroy the file associate with the attribute. * @@ -451,22 +465,4 @@ class FileStorageHelper $filename = trim($filename, '.-'); return $filename; } - - /** - * Remove all model files for the given Model. - * - * @param \Illuminate\Database\Eloquent\Model $model - * @return void - */ - public static function removeModelFiles(Model $model): void - { - $tableName = $model::query()->getModel()->getTable(); - - if (!empty(Storage::disk('public')->allFiles("modelfiles/{$tableName}"))) { - Storage::disk('public')->deleteDirectory("modelfiles/{$tableName}"); - } - if (!empty(Storage::disk('private')->allFiles("modelfiles/{$tableName}"))) { - Storage::disk('private')->deleteDirectory("modelfiles/{$tableName}"); - } - } }