Skip to content

Firefly III: a personal finances manager

API: Unified attachment_* and model_* for Attachments

Geoffrey “Frogeye” Preud'hommee81ce3317c17
diff --git a/app/Api/V1/Requests/AttachmentStoreRequest.php b/app/Api/V1/Requests/AttachmentStoreRequest.php
index e7b0326bb9..6fc7a89354 100644
--- a/app/Api/V1/Requests/AttachmentStoreRequest.php
+++ b/app/Api/V1/Requests/AttachmentStoreRequest.php
@@ -57,8 +57,8 @@ class AttachmentStoreRequest extends Request
'filename' => $this->string('filename'),
'title' => $this->string('title'),
'notes' => $this->nlString('notes'),
- 'model' => $this->string('model'),
- 'model_id' => $this->integer('model_id'),
+ 'model' => $this->string('attachable_type'),
+ 'model_id' => $this->integer('attachable_id'),
];
}
@@ -77,14 +77,14 @@ class AttachmentStoreRequest extends Request
str_replace('FireflyIII\\Models\\', '', TransactionJournal::class),
]
);
- $model = $this->string('model');
+ $model = $this->string('attachable_type');
return [
- 'filename' => 'required|between:1,255',
- 'title' => 'between:1,255',
- 'notes' => 'between:1,65000',
- 'model' => sprintf('required|in:%s', $models),
- 'model_id' => ['required', 'numeric', new IsValidAttachmentModel($model)],
+ 'filename' => 'required|between:1,255',
+ 'title' => 'between:1,255',
+ 'notes' => 'between:1,65000',
+ 'attachable_type' => sprintf('required|in:%s', $models),
+ 'attachable_id' => ['required', 'numeric', new IsValidAttachmentModel($model)],
];
}
}
diff --git a/app/Api/V1/Requests/AttachmentUpdateRequest.php b/app/Api/V1/Requests/AttachmentUpdateRequest.php
index f5675b7f53..60a69c612b 100644
--- a/app/Api/V1/Requests/AttachmentUpdateRequest.php
+++ b/app/Api/V1/Requests/AttachmentUpdateRequest.php
@@ -52,8 +52,8 @@ class AttachmentUpdateRequest extends Request
'filename' => $this->string('filename'),
'title' => $this->string('title'),
'notes' => $this->nlString('notes'),
- 'model' => $this->string('model'),
- 'model_id' => $this->integer('model_id'),
+ 'model' => $this->string('attachable_type'),
+ 'model_id' => $this->integer('attachable_id'),
];
}