diff --git a/README.md b/README.md index a155c17..540672a 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ php artisan vendor:publish --tag="filament-email-config" Register the plugin through your panel service provider: ```php -->plugin(new \RickDBCN\FilamentEmail\FilamentEmail::make()) +->plugin(\RickDBCN\FilamentEmail\FilamentEmail::make()) ``` ## Configuration diff --git a/resources/views/raw_body.blade.php b/resources/views/raw_body.blade.php index b8459fb..0d0d090 100644 --- a/resources/views/raw_body.blade.php +++ b/resources/views/raw_body.blade.php @@ -1,8 +1,10 @@ @php $content = $getRecord()->raw_body; - $path = storage_path('app' . DIRECTORY_SEPARATOR . $content); - if (file_exists($path)) { - $content = file_get_contents($path); + if (!empty($content)) { + $path = storage_path('app' . DIRECTORY_SEPARATOR . $content); + if (file_exists($path)) { + $content = file_get_contents($path); + } } @endphp diff --git a/src/Models/Email.php b/src/Models/Email.php index cffc97b..e6ffdb6 100644 --- a/src/Models/Email.php +++ b/src/Models/Email.php @@ -60,13 +60,14 @@ public static function boot() array_pop($parts); $folderPath = implode(DIRECTORY_SEPARATOR, $parts); } - if (file_exists($filePath)) { + if (! is_dir($filePath) && file_exists($filePath)) { unlink($filePath); } } } - $savePathRaw = storage_path('app' . DIRECTORY_SEPARATOR . $record->raw_body); - if (file_exists($savePathRaw)) { + + $savePathRaw = storage_path('app'.DIRECTORY_SEPARATOR.$record->raw_body); + if (! is_dir($savePathRaw) && file_exists($savePathRaw)) { if (empty($folderPath)) { $parts = explode(DIRECTORY_SEPARATOR, $savePathRaw); array_pop($parts); @@ -74,7 +75,7 @@ public static function boot() } unlink($savePathRaw); } - if (file_exists($folderPath)) { + if (is_dir($folderPath) && file_exists($folderPath)) { rmdir($folderPath); } });