diff --git a/resources/js/Components/Pages/RecordsPage.jsx b/resources/js/Components/Pages/RecordsPage.jsx index 2de300978..0397bb1b5 100644 --- a/resources/js/Components/Pages/RecordsPage.jsx +++ b/resources/js/Components/Pages/RecordsPage.jsx @@ -235,8 +235,11 @@ export default class RecordsPage extends Page { data[key] = field.value; }); - // noinspection JSUnresolvedFunction - const response = await this.model.create(data); + // eslint-disable-next-line new-cap + const instance: Model = new this.model(); + instance.setAttributes(data); + + const response = await instance.save(); if (response.getModelId()) { dialog.get(0) .close(); diff --git a/resources/js/Models/Model.js b/resources/js/Models/Model.js index ddff8cc29..ebdd34929 100644 --- a/resources/js/Models/Model.js +++ b/resources/js/Models/Model.js @@ -13,6 +13,16 @@ export default class Model extends BaseModel { return super.getAttribute(attributeName); } + setAttribute(attributeName: string, value: any): void { + super.setAttribute(attributeName, value); + } + + setAttributes(attributes: { [string]: any }): void { + for (const [attribute, value] of Object.entries(attributes)) { + this.setAttribute(attribute, value); + } + } + getJsonApiBaseUrl(): string { return '/api'; }