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