dealhub/app/Services/FileService.php
kusowl ccb5a2ed5e refactor: consolidate alert components and improve functionality
- replaced `alert-error` and `alert-success` components with a single reusable `alert` component
- added JS functionality for dismissible alerts
- updated related views to use the new `alert` component
- adjusted broker profile logic to display initials and verification status dynamically
- refactored morph relations from `type` to `role`
- enhanced image preview behavior for file inputs
- made broker migration fields nullable and added safeguards against registration errors
- Added confirmation when a user wants delete deal
- Add dynamic initials for user profile picture
- make image file name non-overidding with timestamp
2026-01-14 12:19:20 +05:30

25 lines
594 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
{
// This prevents overriding of same image name
$filename = time().$filename.'.'.$file->extension();
return $file->storeAs($folder, $filename, 'public');
}
public function delete(?string $path): void
{
if ($path && Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
}
}