protected function applySortingToQueryBuilder($query, $source, $direction = 'asc', $strategy = null)
    {
        $source = $source ?: $query->getModel()->getKeyName();

        // Prepare the sorting strategy
        if (null === $strategy) {
            $strategy = config('cms-models.meta-references.sort-strategy');
        }

        if ( ! $strategy) return $this;


        $strategyInstance = new $strategy;

        if ( ! ($strategyInstance instanceof SortStrategyInterface)) {
            throw new UnexpectedValueException("{$strategy} is not a sort strategy");
        }

        // Explode combined source keys and apply the strategy for each part
        foreach (explode(',', $source) as $sourcePart) {

            $query = $strategyInstance->apply($query, $sourcePart, $direction);
        }

        return $this;
    }