Feat: Updating FIle Services, Updating Order Views to list product extra options

This commit is contained in:
2026-09-25 10:08:57 +03:00
parent 2b8fe5764c
commit 6025ea4304
10 changed files with 332 additions and 13 deletions
+18 -2
View File
@@ -20,6 +20,12 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
* (3dealer's custom-field upload flow today, some other future
* file-upload need tomorrow) supplies its own `purpose` string and owner
* model, and scopes its own queries by them.
*
* `purpose` also doubles as the storage directory a file lands under
* (store() passes it straight through as the adapter's own $directory) —
* one string to name both, rather than every caller supplying two
* near-identical values for what's really the same distinction ("which
* kind of upload is this").
*/
class FileService
{
@@ -27,9 +33,9 @@ class FileService
private readonly Container $container,
) {}
public function store(UploadedFile $file, string $purpose, string $directory, string $disk = 'local'): File
public function store(UploadedFile $file, string $purpose, string $disk = 'local'): File
{
$path = $this->adapter($disk)->store($file, $directory);
$path = $this->adapter($disk)->store($file, $purpose);
return File::create([
'disk' => $disk,
@@ -62,6 +68,16 @@ class FileService
return $this->adapter($file->disk)->retrieve($file->path, $file->original_name);
}
/**
* Same file as retrieve(), forced as a download (Content-Disposition:
* attachment) rather than served inline — for a button distinct from
* a preview link/thumbnail pointing at the same File.
*/
public function download(File $file): StreamedResponse
{
return $this->adapter($file->disk)->download($file->path, $file->original_name);
}
public function exists(File $file): bool
{
return $this->adapter($file->disk)->exists($file->path);