当前位置: 首页>>代码示例>>PHP>>正文


PHP Builder::orderBy方法代码示例

本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::orderBy方法的具体用法?PHP Builder::orderBy怎么用?PHP Builder::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Eloquent\Builder的用法示例。


在下文中一共展示了Builder::orderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onQuerying

 /**
  * Fired just before querying
  * for table entries.
  *
  * @param Builder $query
  */
 public function onQuerying(Builder $query)
 {
     $uploaded = $this->getUploaded();
     $query->whereIn('id', $uploaded ?: [0]);
     $query->orderBy('updated_at', 'ASC');
     $query->orderBy('created_at', 'ASC');
 }
开发者ID:tobz-nz,项目名称:file-field_type,代码行数:13,代码来源:UploadTableBuilder.php

示例2: orderBy

 /**
  * Adds a OrderBy to the query
  *
  * @param  string
  * @param  string
  * @return $this
  */
 public function orderBy($column, $order = 'asc')
 {
     if ($column != null) {
         $this->query->orderBy($column, $order);
     }
     return $this;
 }
开发者ID:lykegenes,项目名称:laravel-api-response,代码行数:14,代码来源:EloquentQueryStrategy.php

示例3: applyOrderBy

 /**
  * @param string $column
  * @param string $direction
  * @return $this
  */
 public function applyOrderBy($column, $direction = 'asc')
 {
     /**
      * Save to conditons.
      */
     $this->addCondition('order by', [$column, $direction]);
     $this->model = $this->model->orderBy($column, $direction);
     return $this;
 }
开发者ID:aaronjan,项目名称:housekeeper,代码行数:14,代码来源:Plan.php

示例4: orderByColumns

 /**
  * Order by columns based on parameters
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param string $orderBy
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public static function orderByColumns(Builder $query, $orderBy)
 {
     if (Request::has('orderbycolumn') == TRUE && Request::has('orderbytype') == TRUE) {
         $query->orderBy(Request::input('orderbycolumn'), Request::input('orderbytype'));
     } else {
         foreach ($orderBy as $orderByColumn => $orderByType) {
             $query->orderBy($orderByColumn, $orderByType);
         }
     }
     return $query;
 }
开发者ID:jdrda,项目名称:olapus,代码行数:18,代码来源:Helpers.php

示例5: scopeSort

 /**
  * Sort
  *
  * @param \Illuminate\Database\Eloquent\Builder $builder
  * @param string|null                           $sort    Optional sort string
  *
  * @return \Illuminate\Database\Query\Builder
  */
 public function scopeSort(Builder $builder, $sort = null)
 {
     if ((is_null($sort) || empty($sort)) && Input::has($this->getSortParameterName())) {
         $sort = Input::get($this->getSortParameterName());
     }
     if (!is_null($sort)) {
         $sort = explode(',', $sort);
         foreach ($sort as $field) {
             $field = trim($field);
             $order = 'asc';
             switch ($field[0]) {
                 case '-':
                     $field = substr($field, 1);
                     $order = 'desc';
                     break;
                 case '+':
                     $field = substr($field, 1);
                     break;
             }
             $field = trim($field);
             if (in_array($field, $this->getSortable())) {
                 $builder->orderBy($field, $order);
             }
         }
     }
 }
开发者ID:nathanmac,项目名称:laravel-sortable,代码行数:34,代码来源:SortableTrait.php

示例6: onQuerying

 /**
  * Fired just before querying
  * for table entries.
  *
  * @param Builder $query
  */
 public function onQuerying(Builder $query)
 {
     $uploaded = $this->getUploaded();
     if ($fieldType = $this->getFieldType()) {
         /*
          * If we have the entry available then
          * we can determine saved sort order.
          */
         $entry = $fieldType->getEntry();
         $table = $fieldType->getPivotTableName();
         if ($entry->getId() && !$uploaded) {
             $query->join($table, $table . '.file_id', '=', 'files_files.id');
             $query->where($table . '.entry_id', $entry->getId());
             $query->orderBy($table . '.sort_order', 'ASC');
         } else {
             $query->whereIn('id', $uploaded ?: [0]);
         }
     } else {
         /*
          * If all we have is ID then just use that.
          * The JS / UI will be handling the sort
          * order at this time.
          */
         $query->whereIn('id', $uploaded ?: [0]);
     }
 }
开发者ID:anomalylabs,项目名称:files-field_type,代码行数:32,代码来源:ValueTableBuilder.php

示例7: process

 /**
  * @param Builder $src
  * @param OperationInterface|SortOperation $operation
  * @return mixed
  */
 public function process($src, OperationInterface $operation)
 {
     $field = $operation->getField();
     $order = $operation->getOrder();
     $src->orderBy($field, $order);
     return $src;
 }
开发者ID:view-components,项目名称:eloquent-data-processing,代码行数:12,代码来源:SortProcessor.php

示例8: scopeSort

 /**
  * Adds a sort scope.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param string                                $column
  * @param string                                $direction
  *
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeSort(Builder $query, $column, $direction)
 {
     if (!in_array($column, $this->sortable)) {
         return $query;
     }
     return $query->orderBy($column, $direction);
 }
开发者ID:aksalj,项目名称:Cachet,代码行数:16,代码来源:SortableTrait.php

示例9: parseSort

 protected function parseSort(array $params, Query $query)
 {
     if (!isset($params['sort'])) {
         return $query->orderBy('id', 'desc');
     }
     $column = strtolower($params['sort']);
     $direction = 'asc';
     if (strpos($params['sort'], '-') === 0) {
         $direction = 'desc';
         $column = ltrim($column, '-');
     }
     if (!in_array($column, Unit::getColumns())) {
         return $query->orderBy('id', 'desc');
     }
     return $query->orderBy($column, $direction);
 }
开发者ID:xandros15,项目名称:aigisu,代码行数:16,代码来源:UnitSearch.php

示例10: apply

 public function apply(Builder $builder, Model $model)
 {
     $table = $model->getTable();
     $columns = $model->getDefaultOrderableColumns() ?: [];
     foreach ($columns as $column => $order) {
         $builder->orderBy("{$table}.{$column}", $order);
     }
 }
开发者ID:laratools,项目名称:laratools,代码行数:8,代码来源:DefaultOrderableScope.php

示例11: apply

 /**
  * Apply scope on the query
  *
  * @param \Illuminate\Database\Eloquent\Builder $builder
  * @param \Illuminate\Database\Eloquent\Model   $model
  */
 public function apply(Builder $builder, Model $model)
 {
     $columns = $model->getQualifiedOrderByColumns();
     foreach ($columns as $column => $direction) {
         $builder->orderBy($column, $direction);
     }
     $this->addUnordered($builder);
 }
开发者ID:czim,项目名称:laravel-pxlcms,代码行数:14,代码来源:CmsOrderedScope.php

示例12: sortBy

 /**
  * @param $field
  * @param $direction
  *
  * @return $this
  */
 protected function sortBy($field, $direction)
 {
     if (!in_array($direction, [DoplioDbTable::SORT_ASC, DoplioDbTable::SORT_DESC])) {
         throw new \InvalidArgumentException(sprintf('%s is an invalid sort direction'), $direction);
     }
     $this->specificationQuery->orderBy($field, $direction);
     return $this;
 }
开发者ID:middleout,项目名称:doplio,代码行数:14,代码来源:AbstractRepository.php

示例13: scopeOrder

 /**
  * Orders a given query.
  * 
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeOrder($query)
 {
     if ($this->orderBy[0] !== null and $this->orderBy[1] !== null) {
         return $query->orderBy($this->orderBy[0], $this->orderBy[1]);
     }
     // If the orderBy values are invalid, let's just return the query for now.
     return $query;
 }
开发者ID:stillat,项目名称:database,代码行数:14,代码来源:Model.php

示例14: apply

 /**
  * Applies criterion to query.
  *
  * @param Builder $builder query builder
  */
 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());
     }
 }
开发者ID:bdsoha,项目名称:sortable,代码行数:14,代码来源:Criterion.php

示例15: direction

 /**
  * Set the direction of the query.
  *
  * @param  string|null $direction The date direction to order by
  * @return Parser                 The parser instance itself
  */
 public function direction($direction = null)
 {
     if ($direction == 'Latest') {
         $this->query->orderBy('created_at', 'desc');
     } elseif ($direction == 'Oldest') {
         $this->query->orderBy('created_at', 'asc');
     }
     return $this;
 }
开发者ID:pushoperations,项目名称:magician,代码行数:15,代码来源:Parser.php


注:本文中的Illuminate\Database\Eloquent\Builder::orderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。