| 123456789101112131415161718192021222324252627 |
- <?php
- namespace App\Traits;
- use Exception;
- use Illuminate\Support\Facades\Storage;
- trait RemoveArchiveS3
- {
- /**
- * Delete a file and return a boolean if succeded.
- *
- * @throws \Exception If the file as not found or if the deletion failed.
- */
- public function removeArchiveByPath(string $path): bool
- {
- if (! Storage::exists($path)) {
- return false;
- }
- if (! Storage::delete($path)) {
- throw new Exception('Deletion was not possible');
- }
- return true;
- }
- }
|