Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

monicahq/monica

23656 stars
2 code files
View monicahq/monica on GitHub

app/Exceptions/FileNotFoundException.php

Open in GitHub
use 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 GitHub
use 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;
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.