Persist metadata in ticket management uploads
This commit is contained in:
parent
c4f5bdcb72
commit
94dce96027
|
|
@ -639,6 +639,7 @@ public function caricaAllegati(): void
|
||||||
}
|
}
|
||||||
|
|
||||||
$saved = 0;
|
$saved = 0;
|
||||||
|
$supportsAttachmentMetadata = Schema::hasColumn('ticket_attachments', 'metadata');
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (! is_object($file) || ! method_exists($file, 'store')) {
|
if (! is_object($file) || ! method_exists($file, 'store')) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -646,7 +647,7 @@ public function caricaAllegati(): void
|
||||||
|
|
||||||
$stored = app(TicketAttachmentUploadService::class)->store($file, 'ticket-gestione/' . $ticket->id);
|
$stored = app(TicketAttachmentUploadService::class)->store($file, 'ticket-gestione/' . $ticket->id);
|
||||||
|
|
||||||
$attachment = TicketAttachment::query()->create([
|
$payload = [
|
||||||
'ticket_id' => $ticket->id,
|
'ticket_id' => $ticket->id,
|
||||||
'ticket_update_id' => null,
|
'ticket_update_id' => null,
|
||||||
'user_id' => Auth::id(),
|
'user_id' => Auth::id(),
|
||||||
|
|
@ -655,7 +656,13 @@ public function caricaAllegati(): void
|
||||||
'mime_type' => $stored['mime'],
|
'mime_type' => $stored['mime'],
|
||||||
'size' => $stored['size'],
|
'size' => $stored['size'],
|
||||||
'description' => $this->descrizioneAllegati ?: 'Allegato da gestione ticket',
|
'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) {
|
if ($attachment instanceof TicketAttachment) {
|
||||||
$this->archiveTicketAttachmentDocument($ticket, $attachment);
|
$this->archiveTicketAttachmentDocument($ticket, $attachment);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user