Customer.php 826 Bytes
Newer Older
Qiang Xue committed
1 2
<?php
namespace yiiunit\data\ar;
Alexander Makarov committed
3

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

Qiang Xue committed
18 19
	public $status2;

20 21 22
	public static $afterSaveInsert = null;
	public static $afterSaveNewRecord = null;

Qiang Xue committed
23
	public static function tableName()
Qiang Xue committed
24 25 26
	{
		return 'tbl_customer';
	}
Qiang Xue committed
27

Qiang Xue committed
28
	public function getOrders()
Qiang Xue committed
29
	{
30
		return $this->hasMany(Order::className(), ['customer_id' => 'id'])->orderBy('id');
Qiang Xue committed
31
	}
32 33 34

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

	public function afterSave($insert)
	{
		static::$afterSaveInsert = $insert;
		static::$afterSaveNewRecord = $this->isNewRecord;
		parent::afterSave($insert);
	}
Zander Baldwin committed
44
}