src/Search/ApplySearchParametersTrait.php
protected function applySort(AbstractSearch $search, array $sort = null)
    {
        $sort = $sort ?: $search->getDefaultSort();

        if (is_callable($sort)) {
            $sort($search->getQuery());
        } else {
            foreach ($sort as $field => $order) {
                if (is_array($order)) {
                    foreach ($order as $value) {
                        $search->getQuery()->orderByRaw(snake_case($field).' != ?', [$value]);
                    }
                } else {
                    $search->getQuery()->orderBy(snake_case($field), $order);
                }
            }
        }
    }
protected function applySort(AbstractSearch $search, array $sort = null)
    {
        $sort = $sort ?: $search->getDefaultSort();

        if (is_callable($sort)) {
            $sort($search->getQuery());
        } else {
            foreach ($sort as $field => $order) {
                if (is_array($order)) {
                    foreach ($order as $value) {
                        $search->getQuery()->orderByRaw(snake_case($field).' != ?', [$value]);
                    }
                } else {
                    $search->getQuery()->orderBy(snake_case($field), $order);
                }
            }
        }
    }
protected function applySort ( AbstractSearch $ search , array $ sort = null ) { $ sort = $ sort ? : $ search -> getDefaultSort ( ) ; if ( is_callable ( $ sort ) ) { $ sort ( $ search -> getQuery ( ) ) ; } else { foreach ( $ sort as $ field => $ order ) { if ( is_array ( $ order ) ) { foreach ( $ order as $ value ) { $ search -> getQuery ( ) -> orderByRaw ( snake_case ( $ field ) . ' != ?' , [ $ value ] ) ; } } else { $ search -> getQuery ( ) -> orderBy ( snake_case ( $ field ) , $ order ) ; } } } }
Apply sort criteria to a discussion search.

@param AbstractSearch $search
@param array $sort
Apply sort criteria to a discussion search .