From c1f73ae6dc88f129a909542f03aa11db9b171904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Fri, 1 Aug 2025 11:53:18 +0300 Subject: [PATCH] add attachment feature to document payments --- app/Jobs/Banking/CreateBankingDocumentTransaction.php | 7 ------- resources/assets/js/mixins/global.js | 10 +++++++--- .../components/documents/show/attachment.blade.php | 11 ++++++----- resources/views/modals/documents/payment.blade.php | 2 ++ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/Jobs/Banking/CreateBankingDocumentTransaction.php b/app/Jobs/Banking/CreateBankingDocumentTransaction.php index 7630c6590..9a818dd80 100644 --- a/app/Jobs/Banking/CreateBankingDocumentTransaction.php +++ b/app/Jobs/Banking/CreateBankingDocumentTransaction.php @@ -38,13 +38,6 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate \DB::transaction(function () { $this->transaction = $this->dispatch(new CreateTransaction($this->request)); - // Upload attachment - if ($this->request->file('attachment')) { - $media = $this->getMedia($this->request->file('attachment'), 'transactions'); - - $this->transaction->attachMedia($media, 'attachment'); - } - $this->model->save(); $this->createHistory(); diff --git a/resources/assets/js/mixins/global.js b/resources/assets/js/mixins/global.js index 350ecd5f6..3a19616ff 100644 --- a/resources/assets/js/mixins/global.js +++ b/resources/assets/js/mixins/global.js @@ -945,15 +945,19 @@ export default { let data = this.form.data(); FormData.prototype.appendRecursive = function(data, wrapper = null) { - for(var name in data) { + for (var name in data) { + if (name == "previewElement" || name == "previewTemplate") { + continue; + } + if (wrapper) { - if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) { + if ((typeof data[name] == 'object' || Array.isArray(data[name])) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) { this.appendRecursive(data[name], wrapper + '[' + name + ']'); } else { this.append(wrapper + '[' + name + ']', data[name]); } } else { - if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) { + if ((typeof data[name] == 'object' || Array.isArray(data[name])) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) { this.appendRecursive(data[name], name); } else { this.append(name, data[name]); diff --git a/resources/views/components/documents/show/attachment.blade.php b/resources/views/components/documents/show/attachment.blade.php index 20c59c637..1ed1e99ac 100644 --- a/resources/views/components/documents/show/attachment.blade.php +++ b/resources/views/components/documents/show/attachment.blade.php @@ -1,5 +1,4 @@ - -@if ($attachment) +@if ($attachment || $transaction_attachment->count()) @stack('timeline_attachment_body_start') - @foreach ($attachment as $file) - - @endforeach + @if ($attachment) + @foreach ($attachment as $file) + + @endforeach + @endif @if ($transaction_attachment->count())
diff --git a/resources/views/modals/documents/payment.blade.php b/resources/views/modals/documents/payment.blade.php index 15b4311cb..c35eaf89b 100644 --- a/resources/views/modals/documents/payment.blade.php +++ b/resources/views/modals/documents/payment.blade.php @@ -123,6 +123,8 @@ + +