fix: attachment file handling - real files, inline preview, click to open
- FileService: use Storage::temporaryUrl() standard API instead of manual signed route - FileService: added isImage() and getPreviewUrl() helpers - Seeder: create actual files on disk instead of fake paths - Edit Feedback: new 'Attachments' section showing all feedback files with thumbnails - Interactions modal: image preview thumbnails + inline click-to-open - New footer layout: edit-footer.blade.php wrapper for attachments + similar cases
This commit is contained in:
@@ -142,7 +142,7 @@ class EditFeedback extends EditRecord
|
||||
|
||||
public function getFooter(): ?View
|
||||
{
|
||||
return view('filament.resources.feedback.similar-cases');
|
||||
return view('filament.resources.feedback.edit-footer');
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
|
||||
@@ -143,6 +143,7 @@ class InteractionsRelationManager extends RelationManager
|
||||
'url' => $fileService->getTemporaryUrl($a, 60),
|
||||
'size' => $a->size ? round($a->size / 1024, 1) . ' KB' : 'N/A',
|
||||
'collection' => $a->collection,
|
||||
'mime_type' => $a->mime_type,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
@@ -74,13 +74,28 @@ class FileService
|
||||
return Storage::disk('public')->url($attachment->path);
|
||||
}
|
||||
|
||||
return URL::temporarySignedRoute(
|
||||
'storage.local',
|
||||
return Storage::disk($attachment->disk)->temporaryUrl(
|
||||
$attachment->path,
|
||||
now()->addMinutes($minutes),
|
||||
['path' => $attachment->path]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a preview (inline) URL vs download URL.
|
||||
*/
|
||||
public function getPreviewUrl(FeedbackAttachment $attachment, int $minutes = 60): string
|
||||
{
|
||||
return $this->getTemporaryUrl($attachment, $minutes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if attachment is an image (for inline preview).
|
||||
*/
|
||||
public function isImage(FeedbackAttachment $attachment): bool
|
||||
{
|
||||
return in_array($attachment->mime_type, ['image/jpeg', 'image/jpg', 'image/png']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all attachments of a specific collection for a model.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user