Instance configuration

Configure the data model with the following constants.

table

Set the namephp of the table the data model should use. Include a tableAlias by setting it as an array.

const table = 'users';

Include a tableAlias.

const table = ['u' => 'users'];

fillable

The fillable constant restricts the set() method, to only write to the defined columns.

const fillable = [
    'firstName',
    'lastName',
    'email',
    'category'
];

hidden

Suppress the column output to null. Useful to hide data from f.ex. columns like password.

const hidden = [
    'password'
];

dates

The dates constant tells methods like insert(), update() and delete() to set the current time in the corresponding timestamp columns.

const dates = [
    'created_at',
    'updated_at',
    'deleted_at'
];

softDelete

Setting the softDelete option will affect these methods:

  • Force SELECT methods to only return rows where deleted_at is null.

  • delete() : will not delete the row, but mark deleted_at with the current time.

const softDelete = true;

Last updated