Persist metadata in ticket management uploads

This commit is contained in:
michele 2026-04-12 20:03:26 +00:00
parent c4f5bdcb72
commit 94dce96027

View File

@ -639,6 +639,7 @@ public function caricaAllegati(): void
}
$saved = 0;
$supportsAttachmentMetadata = Schema::hasColumn('ticket_attachments', 'metadata');
foreach ($files as $file) {
if (! is_object($file) || ! method_exists($file, 'store')) {
continue;
@ -646,7 +647,7 @@ public function caricaAllegati(): void
$stored = app(TicketAttachmentUploadService::class)->store($file, 'ticket-gestione/' . $ticket->id);
$attachment = TicketAttachment::query()->create([
$payload = [
'ticket_id' => $ticket->id,
'ticket_update_id' => null,
'user_id' => Auth::id(),
@ -655,7 +656,13 @@ public function caricaAllegati(): void
'mime_type' => $stored['mime'],
'size' => $stored['size'],
'description' => $this->descrizioneAllegati ?: 'Allegato da gestione ticket',
]);
];
if ($supportsAttachmentMetadata) {
$payload['metadata'] = is_array($stored['metadata'] ?? null) ? $stored['metadata'] : [];
}
$attachment = TicketAttachment::query()->create($payload);
if ($attachment instanceof TicketAttachment) {
$this->archiveTicketAttachmentDocument($ticket, $attachment);