| 12345678910111213141516171819202122232425262728 |
- <?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)) {
- $success = Storage::delete($path);
- if ($success) {
- return true;
- } else {
- throw new Exception('Deletion was not possible');
- }
- } else {
- throw new Exception('File not found');
- }
- }
- }
|