getSortByField() public method

Returns the query builders sort by field.
public getSortByField ( ) : string
return string
Example #1
0
 /**
  * Sorts LDAP search results.
  *
  * @param array $models
  *
  * @return array
  */
 private function processSort(array $models = [])
 {
     $collection = $this->newCollection($models);
     $sort = [$this->builder->getSortByField() => $this->builder->getSortByDirection()];
     $criteria = (new Criteria())->orderBy($sort);
     return $collection->matching($criteria)->toArray();
 }
Example #2
0
 /**
  * Sorts LDAP search results.
  *
  * @param array $models
  *
  * @return Collection
  */
 protected function processSort(array $models = [])
 {
     $field = $this->builder->getSortByField();
     $flags = $this->builder->getSortByFlags();
     $direction = $this->builder->getSortByDirection();
     $desc = $direction === 'desc' ? true : false;
     return $this->newCollection($models)->sortBy(function (Model $model) use($field) {
         return $model->getAttribute($field, 0);
     }, $flags, $desc);
 }
Example #3
0
 /**
  * Sorts LDAP search results.
  *
  * @param array $models
  *
  * @return Collection
  */
 protected function processSort(array $models = [])
 {
     $collection = $this->newCollection($models);
     $field = $this->builder->getSortByField();
     $direction = $this->builder->getSortByDirection();
     if ($direction === 'desc') {
         $sorted = $collection->sortByDesc($field);
     } else {
         $sorted = $collection->sortBy($field);
     }
     return $sorted;
 }