Customer.php 900 Bytes
Newer Older
1 2 3
<?php
namespace yiiunit\data\ar\elasticsearch;

4
use yiiunit\extensions\elasticsearch\ActiveRecordTest;
5

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/**
 * Class Customer
 *
 * @property integer $id
 * @property string $name
 * @property string $email
 * @property string $address
 * @property integer $status
 */
class Customer extends ActiveRecord
{
	const STATUS_ACTIVE = 1;
	const STATUS_INACTIVE = 2;

	public $status2;

22
	public function attributes()
23
	{
24
		return ['name', 'email', 'address', 'status'];
25 26 27 28
	}

	public function getOrders()
	{
29
		return $this->hasMany(Order::className(), array('customer_id' => ActiveRecord::PRIMARY_KEY_NAME))->orderBy('create_time');
30 31 32 33
	}

	public static function active($query)
	{
34
		$query->andWhere(array('status' => 1));
35
	}
36 37 38 39 40 41 42

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