Database
  • Get started
    • Database for PHP
    • Install / configure
    • Quick reference
  • Dbi
    • Instance model
    • Instance configuration
    • Instance methods
    • Query examples
  • Dba
    • Query builder
    • Put Methods
    • Scope Methods
    • Return Methods
  • SQLI
    • Query execution
    • Request Methods
    • Query Methods
Powered by GitBook
On this page
  • table
  • fillable
  • hidden
  • dates
  • softDelete
  1. Dbi

Instance configuration

Configure the data model with the following constants.

  • table

  • fillable

  • hidden

  • dates

  • softDelete

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;

PreviousInstance modelNextInstance methods

Last updated 1 year ago