Eloquent: Models

Introduction

Kiaan includes Eloquent, an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using Eloquent, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, Eloquent models allow you to insert, update, and delete records from the table as well.

Generating Model Classes

To get started, let's create an Eloquent model.

Models typically live in the databases\models directory and extend the Kiaan\Database\DB\Build\Model class.

You may use the model:create command to generate a new model:

php kiaan model:create Pages

Table Names

You may manually specify the model's table name by defining a table property on the model:

class Pages extends Model implements ModelBuild {

    /*
    * Class
    *
    */
    protected static $__CLASS__ = __CLASS__; 

    /*
    * Table
    *
    */
    protected $table = "pages"; 

}

Last updated