mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-22 23:17:12 +01:00
- allows to have dynamic definition of attributes depended on the instance - there was no real need for it to be static. Places that used it static have been refactored. fixes #1318
38 lines
713 B
PHP
38 lines
713 B
PHP
<?php
|
|
|
|
namespace yiiunit\data\ar\redis;
|
|
|
|
use yiiunit\extensions\redis\ActiveRecordTest;
|
|
|
|
class Customer extends ActiveRecord
|
|
{
|
|
const STATUS_ACTIVE = 1;
|
|
const STATUS_INACTIVE = 2;
|
|
|
|
public $status2;
|
|
|
|
public function attributes()
|
|
{
|
|
return ['id', 'email', 'name', 'address', 'status'];
|
|
}
|
|
|
|
/**
|
|
* @return \yii\redis\ActiveRelation
|
|
*/
|
|
public function getOrders()
|
|
{
|
|
return $this->hasMany(Order::className(), ['customer_id' => 'id']);
|
|
}
|
|
|
|
public static function active($query)
|
|
{
|
|
$query->andWhere(['status' => 1]);
|
|
}
|
|
|
|
public function afterSave($insert)
|
|
{
|
|
ActiveRecordTest::$afterSaveInsert = $insert;
|
|
ActiveRecordTest::$afterSaveNewRecord = $this->isNewRecord;
|
|
parent::afterSave($insert);
|
|
}
|
|
} |