/**
  * @param Builder $builder
  * @param SortParameterInterface $param
  */
 protected function sortBy(Builder $builder, SortParameterInterface $param)
 {
     $column = $this->getQualifiedSortColumn($builder, $param->getField());
     $order = $param->isAscending() ? 'asc' : 'desc';
     $builder->orderBy($column, $order);
 }
 /**
  * @param JsonLibrarySortParameterInterface $sortParameter
  *
  * @return SortParameterInterface|null
  */
 protected function mapSortField(JsonLibrarySortParameterInterface $sortParameter)
 {
     $this->resetSchema();
     $mappedParam = null;
     $jsonName = $sortParameter->getField();
     if ($this->isId($jsonName) === true) {
         $column = $this->getModelSchemes()->getPrimaryKey($this->getCurrentModelClass());
         $mappedParam = $this->createSortAttributeParameter($sortParameter, $column);
     } elseif ($this->canMapAttribute($jsonName) === true) {
         $column = $this->getAttributeMappings()[$jsonName];
         $mappedParam = $this->createSortAttributeParameter($sortParameter, $column);
     } elseif ($this->canMapRelationship($jsonName) === true) {
         $modelName = $this->getRelationshipMappings()[$jsonName];
         $type = $this->getModelSchemes()->getRelationshipType($this->getCurrentModelClass(), $modelName);
         if ($type === RelationshipTypes::BELONGS_TO) {
             $mappedParam = $this->createSortRelationshipParameter($sortParameter, $modelName, $type);
         }
     }
     return $mappedParam;
 }
 /**
  * @inheritdoc
  */
 public function isAscending()
 {
     return $this->libSortParam->isAscending();
 }