-
app/Exceptions/FileNotFoundException.php
Open in GitHubuse Illuminate\Contracts\Filesystem\FileNotFoundException as FileNotFoundExceptionBase; class FileNotFoundException extends FileNotFoundExceptionBase { public $fileName; public function __construct($fileName) { $this->fileName = $fileName; parent::__construct(); } public function __toString() { return 'File not found: '.$this->fileName; } }
-
app/Services/Account/Settings/DestroyAllDocuments.php
Open in GitHubuse App\Services\BaseService; use App\Models\Contact\Document; use Illuminate\Support\Facades\Storage; use Illuminate\Contracts\Filesystem\FileNotFoundException; class DestroyAllDocuments extends BaseService { // public function execute(array $data): bool { $this->validate($data); $documents = Document::where('account_id', $data['account_id']) ->get(); foreach ($documents as $document) { try { Storage::delete($document->new_filename); } catch (FileNotFoundException $e) { continue; } $document->delete(); } return true; } }