-
Notifications
You must be signed in to change notification settings - Fork 48
README Example Support Files
Romans Malinovskis edited this page May 31, 2016
·
3 revisions
class Model_User extends atk4\data\Model
{
protected $table = 'user';
function init() {
parent::init();
$this->addField('name');
$this->addField('surname');
$this->addField('is_client', ['type'=>'boolean']);
}
}
class Model_Client extends Model_User {
function init() {
parent::init();
$this->addField('is_vip', ['type'=>'boolean']);
$this->addCondition('is_client', true);
$this->hasMany('Order');
}
}
class Model_Item extends atk4\data\Model {
protected $table = 'item';
function init() {
parent::init();
$this->addField('name');
$this->addField('price', ['type'=>'money']);
}
}
class Model_Order extends atk4\data\Model {
protected $table = 'order';
function init() {
parent::init();
$this->hasOne('Client'); // not User
$this->hasOne('Item');
}
}
Agile Data, Documentation and Wiki content is licensed under MIT and (c) by Agile Toolkit Limited UK