import SoftDeletes from './Concerns/SoftDeletes'; import FactoryBuilder from './Factory/FactoryBuilder'; import type HasFactory from '../Contracts/HasFactory'; import type { Attributes, AttributeKeys, SimpleAttributes } from './Concerns/HasAttributes'; import ModelCollection from './ModelCollection'; import type { MaybeArray, StaticToThis } from '../Support/type'; export default class Model extends SoftDeletes implements HasFactory { /** * The primary key for the model. * * @type {string} * * @protected */ protected get primaryKey(): string; /** * The type of the key that acts as the primary key of the model. * * @type {'number' | 'string'} * * @protected */ protected get keyType(): 'number' | 'string'; /** * Indicates whether the model exists on the backend or not. * * @type {boolean} */ get exists(): boolean; /** * Get the primary key for the model. * * @type {string} */ getKeyName(): string; /** * Get the primary key for the model. * * @return {string|number} */ getKey(): (T extends 'number' ? number : string) | undefined; /** * Construct a new model from context. * * @param {(object | Model)=} attributes * * @return {this} */ new(attributes?: Attributes | this): this; /** * Construct a new model instance. * * @param {(object | Model)=} attributes * * @return {this} */ static make(this: StaticToThis, attributes?: Attributes): StaticToThis['prototype']; /** * Clone the model into a non-exiting instance. * * @param {string[]|string} except */ replicate(except?: MaybeArray | string>): this; /** * Creates a one-to-one copy of the model without copying by reference. * * @return {this} */ clone(): this; /** * Determine if two models have the same key and of the same type. * * @param {any} model * * @return {boolean} */ is(model: unknown): model is M; /** * Determine if two models are not the same. * * @param {any} model * * @see Model.prototype.is * * @return {boolean} */ isNot(model: unknown): model is Exclude; /** * Gets the current class' name. * * For more information check the {@link https://upfrontjs.com/calliope/#getname|documentation} * * @return {string} */ getName(): string; /** * Call the provided function with the model if the given value is true. * * @param {any} val * @param {function} closure * * @return {this} */ when(val: any, closure: (instance: this) => any): this; /** * Call the provided function with the model if the given value is false. * * @param {any} val * @param {function} closure * * @return {this} */ unless(val: any, closure: (instance: this) => any): this; /** * Pass a clone of the model to a given function. * * @param callback */ tap(callback: (model: this) => void): this; /** * Call the factory fluently from the model. */ static factory(this: T, times?: number): FactoryBuilder; /** * Get all the models. * * @return {Promise} */ static all(this: T): Promise>; /** * Save or update the model. * * @param {object=} data */ save(data?: SimpleAttributes): Promise; /** * Set the correct endpoint and initiate a patch request. * * @param {object} data * * @see CallsApi.prototype.patch */ update(data: SimpleAttributes): Promise; /** * Find the model based on the given id. * * @param {string|number} id */ static find(this: T, id: number | string): Promise; /** * Return multiple models based on the given ids. * * @param {string[]|number[]} ids */ static findMany(this: T, ids: (number | string)[]): Promise>; /** * Refresh the attributes from the backend. * * @return {Promise} */ refresh(): Promise; } //# sourceMappingURL=Model.d.ts.map