Customer.php 713 Bytes
Newer Older
1 2 3 4
<?php

namespace yiiunit\data\ar\redis;

5
use yiiunit\extensions\redis\ActiveRecordTest;
6

7 8 9 10 11 12 13
class Customer extends ActiveRecord
{
	const STATUS_ACTIVE = 1;
	const STATUS_INACTIVE = 2;

	public $status2;

14
	public function attributes()
15 16 17 18
	{
		return ['id', 'email', 'name', 'address', 'status'];
	}

19
	/**
20
	 * @return \yii\redis\ActiveRelation
21 22 23
	 */
	public function getOrders()
	{
24
		return $this->hasMany(Order::className(), ['customer_id' => 'id']);
25 26
	}

27 28
	public static function active($query)
	{
29
		$query->andWhere(['status' => 1]);
30
	}
31 32 33 34 35 36 37

	public function afterSave($insert)
	{
		ActiveRecordTest::$afterSaveInsert = $insert;
		ActiveRecordTest::$afterSaveNewRecord = $this->isNewRecord;
		parent::afterSave($insert);
	}
38
}