field->{'relation'}(); } catch (Exception) { throw new Exception("'relation' method is required for the aggregate sort type"); } return $builder->withCount($relation)->orderBy("{$relation}_count", $this->direction->value); } }