public function apply(Builder $builder)
    {
        $sortMethod = 'sort' . studly_case($this->getField());

        if(method_exists($builder->getModel(), $sortMethod)) {
            call_user_func_array([$builder->getModel(), $sortMethod], [$builder, $this->getOrder()]);
        } else {
            $builder->orderBy($this->getField(), $this->getOrder());
        }
    }
public function apply(Builder $builder)
    {
        $sortMethod = 'sort' . studly_case($this->getField());

        if(method_exists($builder->getModel(), $sortMethod)) {
            call_user_func_array([$builder->getModel(), $sortMethod], [$builder, $this->getOrder()]);
        } else {
            $builder->orderBy($this->getField(), $this->getOrder());
        }
    }
public function apply ( Builder $ builder ) { $ sortMethod = 'sort' . studly_case ( $ this -> getField ( ) ) ; if ( method_exists ( $ builder -> getModel ( ) , $ sortMethod ) ) { call_user_func_array ( [ $ builder -> getModel ( ) , $ sortMethod ] , [ $ builder , $ this -> getOrder ( ) ] ) ; } else { $ builder -> orderBy ( $ this -> getField ( ) , $ this -> getOrder ( ) ) ; } }
Applies criterion to query.

@param Builder $builder query builder
Applies criterion to query .