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