1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-24 23:37:51 +01:00
2021-10-11 19:57:42 +02:00

29 lines
623 B
JavaScript
Vendored

import {
Model as BaseModel,
PluralResponse
} from 'coloquent';
import {snakeCase} from 'lodash-es';
export default class Model extends BaseModel {
/**
* Just an alias to the get() method
*/
static all(): Promise<PluralResponse<InstanceType<Model>>> {
return this.get();
}
setAttributes(attributes: { [string]: any }): void {
for (const [attribute, value] of Object.entries(attributes)) {
this[attribute] = value;
}
}
getJsonApiBaseUrl(): string {
return '/api';
}
getJsonApiType(): string {
return (super.getJsonApiType() ?? snakeCase(this.constructor.name));
}
}