當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model::orderBy方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Model::orderBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::orderBy方法的具體用法?PHP Model::orderBy怎麽用?PHP Model::orderBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::orderBy方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: all

 /**
  * Retorna todos os registros deste Model.
  *
  * @param array $columns Colunas desejadas no retorno.
  *
  * @return mixed
  */
 public function all($columns = ['*'])
 {
     if (!empty($this->defaultOrderColumn)) {
         return $this->model->orderBy($this->defaultOrderColumn, $this->defaultOrderDirection)->get($columns);
     }
     return $this->model->get($columns);
 }
開發者ID:lfalmeida,項目名稱:lbase,代碼行數:14,代碼來源:Repository.php

示例3: orderBy

 /**
  * Order the results by the given column in the given direction.
  *
  * @param string      $key
  * @param string|null $direction
  * @return $this
  * @throws ModelNotSetException
  */
 public function orderBy($key, $direction = 'asc')
 {
     if (!$this->model) {
         throw new ModelNotSetException('You must set a model to run queries on.');
     }
     $this->model = $this->model->orderBy($key, $direction);
     return $this;
 }
開發者ID:michaeljennings,項目名稱:carpenter,代碼行數:16,代碼來源:Eloquent.php

示例4: applyOrder

 /**
  * @return $this
  */
 public function applyOrder()
 {
     if (count($this->model->getQuery()->orders) === 0) {
         $field = $this->orderField !== null ? $this->orderField : $this->getKeyName();
         $direction = strtolower($this->orderDirection) === 'asc' ? 'asc' : 'desc';
         $this->model = $this->model->orderBy($field, $direction);
     }
     return $this;
 }
開發者ID:sjfinder,項目名稱:repository,代碼行數:12,代碼來源:BaseRepository.php

示例5: browse

 /**
  * List
  * 
  * @param  array  $options
  * @return array
  */
 public static function browse($options = [])
 {
     if (empty($options)) {
         return parent::all();
     }
     if (!empty($options['order'])) {
         foreach ($options['order'] as $field => $direction) {
             $find = parent::orderBy($field, $direction);
         }
     }
     if (!empty($options['limit'])) {
         $find = $find->take($options['limit']);
     }
     if (!empty($options['cursor'])) {
         $find = $find->where('id', '<', $options['cursor']);
     }
     return $find->get();
 }
開發者ID:emtudo,項目名稱:laravel-shopping-cart,代碼行數:24,代碼來源:Product.php

示例6: updatePositions

 /**
  * @param int $parent_entity_id
  * @return int
  */
 public function updatePositions(int $parent_entity_id = null)
 {
     // we get the entities concerned by the position incrementation regarding the given previous entity
     if ($parent_entity_id && ($parent_entity = $this->model->find($parent_entity_id))) {
         // if a parent is defined
         // we get the entities hierarchically inferiors to the parent
         $other_entities = $this->model->where('position', '>', $parent_entity->position)->orderBy('position', 'desc')->get();
     } else {
         // if the entity has to be the master one
         // we get all entities
         $other_entities = $this->model->orderBy('position', 'desc')->get();
     }
     // we increment the position of the selected entities
     foreach ($other_entities as $entities) {
         $entities->position += 1;
         $entities->save();
     }
     // we get the new position to apply it to the current entity
     $new_position = isset($parent_entity) ? $parent_entity->position + 1 : 1;
     return $new_position;
 }
開發者ID:Okipa,項目名稱:una.app,代碼行數:25,代碼來源:BaseRepository.php

示例7: orderBy

 /**
  * Sets the order of the next query.
  *
  * @param string $column
  * @param string $order
  *
  * @return void
  */
 public function orderBy($column, $order = 'ASC')
 {
     $this->model = $this->model->orderBy($column, $order);
     return $this;
 }
開發者ID:LavaliteCms,項目名稱:Example,代碼行數:13,代碼來源:BaseRepository.php

示例8: findAll

 public function findAll($orderColumn = 'create_at', $orderDir = 'desc')
 {
     return $this->model->orderBy($orderColumn, $orderDir)->get();
 }
開發者ID:spiritwild,項目名稱:9gagvn,代碼行數:4,代碼來源:BaseRepository.php

示例9: resolveAll

 /**
  * @return array
  */
 public function resolveAll()
 {
     return $this->eloquent->orderBy('id')->get()->toArray();
 }
開發者ID:shin1x1,項目名稱:phpkansai-20151216-demo,代碼行數:7,代碼來源:BookRepository.php

示例10: apply

 /**
  * @param Model      $model
  * @param Repository $repository
  *
  * @return mixed
  */
 public function apply(Model $model, Repository $repository)
 {
     return $model->orderBy($this->column, $this->direction);
 }
開發者ID:draperstudio,項目名稱:eloquent-repositories,代碼行數:10,代碼來源:OrderBy.php

示例11: all

 /**
  * Get all record of a table
  *
  * @param array $columns
  * @param string $order
  * @return mixed
  */
 public function all($columns = array('*'), $order = 'asc')
 {
     return $this->model->orderBy('id', $order)->get($columns);
 }
開發者ID:vnzacky,項目名稱:dog,代碼行數:11,代碼來源:EloquentBaseRepository.php

示例12: orderBy

 public function orderBy($column, $direction = 'asc')
 {
     $this->model = $this->model->orderBy($column, $direction);
     return $this;
 }
開發者ID:eaglesistemas,項目名稱:eaglerepository,代碼行數:5,代碼來源:BaseRepository.php

示例13: orderBy

 /**
  * order by
  * @param $attribute
  * @param bool $desc 默認升序(false), 如需降序, 傳入 true
  * @return static
  */
 public function orderBy($attribute, bool $desc = false)
 {
     $this->original->orderBy($attribute, $desc ? 'desc' : 'asc');
     return $this;
 }
開發者ID:zhwei,項目名稱:laravel-lego,代碼行數:11,代碼來源:EloquentTable.php

示例14: recent

 /**
  * Recent posts
  * @param int $n How many post to show
  */
 public static function recent($n = 5)
 {
     $articles = parent::orderBy('published_at', 'desc')->take($n)->get();
     return $articles;
 }
開發者ID:kaiyulee,項目名稱:express,代碼行數:9,代碼來源:Article.php


注:本文中的Illuminate\Database\Eloquent\Model::orderBy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。