- 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
22 lines
500 B
PHP
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);
|
|
}
|
|
}
|
|
}
|