當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。