dealhub/app/Services/FileService.php
kusowl a248d3fc79 feat(deal update and delete): broker can update and delete their deals
- show external links in listings
- refactor image-input.blade.php to display image while update
- refactor image-input.js to show selected image after user clicks submit
- refactor components to accept default value
- add FileService to handle image update and delete
2026-01-13 15:10:55 +05:30

22 lines
500 B
PHP

<?php
namespace App\Services;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
class FileService
{
public function upload(UploadedFile $file, string $folder, string $filename): string
{
return $file->storeAs($folder, $filename.'.'.$file->extension(), 'public');
}
public function delete(?string $path): void
{
if ($path && Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
}
}