hasMany('Order', array('customer_id' => 'id'))->orderBy('id'); } public static function active($query) { $query->andWhere(array('status' => 1)); } }