array( 'link' => array('customer_id' => 'id'), ), ); } public function orders() { return $this->hasMany('Order', array('id' => 'customer_id')); } /** * @param ActiveQuery $query * @return ActiveQuery */ public function active($query) { return $query->andWhere('@.`status` = ' . self::STATUS_ACTIVE); } }