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


PHP Builder::get方法代码示例

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


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

示例1: get

 /**
  * Get records from the database.
  *
  * @param int $per_page
  *
  * @return Collection
  */
 public function get($per_page = 20)
 {
     $this->per_page = $per_page;
     $this->buildQuery();
     return $this->query->get();
 }
开发者ID:bhutanio,项目名称:laravel-utilities,代码行数:13,代码来源:DbRepository.php

示例2: afterOperations

 /**
  * @param Builder|EloquentBuilder $data
  * @return Traversable
  */
 protected function afterOperations($data)
 {
     if ($data instanceof EloquentBuilder) {
         return $data->get();
     } elseif ($data instanceof Builder) {
         return new ArrayIterator($data->get());
     }
     throw new RuntimeException('Unsupported type of data source.');
 }
开发者ID:view-components,项目名称:eloquent-data-processing,代码行数:13,代码来源:EloquentProcessingService.php

示例3: totalCount

 public function totalCount()
 {
     if ($this->options['distinctCountGroup'] && count($this->originalBuilder->groups) == 1) {
         $this->originalBuilder->groups = null;
     }
     if ($this->options['searchWithAlias']) {
         $cnt = count($this->originalBuilder->get());
     } else {
         $cnt = $this->originalBuilder->count();
     }
     return $cnt;
 }
开发者ID:minkbear,项目名称:datatable,代码行数:12,代码来源:QueryEngine.php

示例4: findWhere

 /**
  * Find data by multiple fields
  *
  * @param array $where
  * @param array $columns
  * @return mixed|Model
  */
 public function findWhere(array $where, $columns = ['*'])
 {
     return $this->wrap(function ($where, $columns = ['*']) {
         $this->applyWhere($where);
         return $this->model->get($columns);
     }, new Action(__METHOD__, func_get_args(), Action::READ));
 }
开发者ID:sandeeprajoria,项目名称:Housekeeper,代码行数:14,代码来源:BaseRepository.php

示例5: getResult

 /**
  * Gets results from prepared query
  *
  * @return null
  */
 protected function getResult()
 {
     if ($this->query_type == 'eloquent') {
         $this->result_object = $this->query->get();
         $this->result_array = $this->result_object->toArray();
     } else {
         $this->result_object = $this->query->get();
         $this->result_array = array_map(function ($object) {
             return (array) $object;
         }, $this->result_object);
     }
     if ($this->dataFullSupport) {
         $walk = function ($value, $key, $prefix = null) use(&$walk, &$result_array) {
             $key = !is_null($prefix) ? $prefix . "." . $key : $key;
             if (is_array($value)) {
                 array_walk($value, $walk, $key);
             } else {
                 $result_array = Arr::add($result_array, $key, $value);
             }
         };
         $result_array = array();
         array_walk($this->result_array, $walk);
         $this->result_array = $result_array;
     }
 }
开发者ID:khaidirh,项目名称:laravel4-datatables-package,代码行数:30,代码来源:Datatables.php

示例6: get

 /**
  * Get all the specified model records in the database
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function get()
 {
     $this->newQuery()->eagerLoad()->setClauses()->setScopes();
     $models = $this->query->get();
     $this->unsetClauses();
     return $models;
 }
开发者ID:Okipa,项目名称:una.app,代码行数:12,代码来源:BaseRepository.php

示例7: getEntities

 /**
  * @return \ArrayIterator|mixed|null
  */
 public function getEntities()
 {
     $result = $this->specificationQuery->get();
     if (0 === $result->count()) {
         return null;
     }
     return $this->mapper->fromDbTableRows($result);
 }
开发者ID:middleout,项目名称:doplio,代码行数:11,代码来源:AbstractRepository.php

示例8: get

 /**
  * Return the elements
  *
  * @return Collection
  */
 public function get()
 {
     // Save the results from the builder
     $results = $this->builder->get();
     // Reset the builder, just in case we are going to use this repository more then once
     $this->newBuilder();
     // Return stuff
     return $results;
 }
开发者ID:kodebyraaet,项目名称:pattern,代码行数:14,代码来源:BaseRepository.php

示例9: findByQueryOrFail

 /**
  * Return a model (or collection of models) for given query or throw an exception. 
  * 
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param int $expectedNoElements
  * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection
  * 
  * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
  */
 public function findByQueryOrFail($query, $expectedNoElements = 1)
 {
     $result = $query->get();
     $noElements = count($result);
     if ($noElements and ($noElements === $expectedNoElements or !is_int($expectedNoElements))) {
         return $result;
     }
     throw (new ModelNotFoundException())->setModel(get_class($query->getModel()));
 }
开发者ID:cichowski,项目名称:spine,代码行数:18,代码来源:BaseModel.php

示例10: items

 public function items(Builder $query)
 {
     $items = [];
     $ids = $query->get(['users.id']);
     foreach ($ids->pluck('id')->all() as $id) {
         $items[] = $this->item($id);
     }
     return $items;
 }
开发者ID:ohiocms,项目名称:core,代码行数:9,代码来源:UserPaginateRequest.php

示例11: get

 /**
  * Execute the query as a "select" statement.
  *
  * @param  array  $columns
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function get($columns = array('*'))
 {
     $results = parent::get($columns);
     switch ($this->returnType) {
         case Builder::RETURN_TYPE_DATAMAPPER:
             return $results->toDatamapperObject();
         case Builder::RETURN_TYPE_ELOQUENT:
             return $results;
     }
 }
开发者ID:proai,项目名称:laravel-datamapper,代码行数:16,代码来源:Builder.php

示例12: get

 /**
  *
  * @param array $columns
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function get($columns = ['*'])
 {
     $this->addCountSub();
     return parent::get($columns)->map(function ($element) {
         foreach ($this->counts as $relation_name => $saved_as) {
             $element->saveCountAssociatedObject($relation_name, $element[$saved_as]);
             unset($element[$saved_as]);
         }
         return $element;
     });
 }
开发者ID:Jchedev,项目名称:laravel-evolved,代码行数:16,代码来源:Builder.php

示例13: paginate

 /**
  * Paginate the results of this query
  *
  * @param  int
  * @param  int
  * @return $this
  */
 public function paginate($perPage, $page)
 {
     if ($perPage > 0) {
         Paginator::currentPageResolver(function () use($page) {
             return $page;
         });
         $this->paginator = $this->query->paginate($perPage);
     } else {
         $this->collection = $this->query->get();
     }
     return $this;
 }
开发者ID:lykegenes,项目名称:laravel-api-response,代码行数:19,代码来源:EloquentQueryStrategy.php

示例14: get

 /**
  * Execute the query as a "select" statement.
  *
  * @param  array $columns
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function get($columns = ['*'])
 {
     $this->orderByDefault();
     if (env('DB_CACHE')) {
         $this->rememberIndex();
         if ($this->model->getTtl()) {
             try {
                 return app('cache')->remember($this->getCacheKey(), $this->model->getTtl(), function () use($columns) {
                     return parent::get($columns);
                 });
             } catch (\Exception $e) {
                 return parent::get($columns);
             }
         }
     }
     return parent::get($columns);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:23,代码来源:EloquentQueryBuilder.php

示例15: get

 /**
  * Create a new Eloficient builder instance.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @return void
  */
 public function get($columns = array("*"))
 {
     if ($this->disableEloficient) {
         return parent::get($columns);
     }
     if ($this->eagerLoad) {
         $this->prepareQuery();
         $this->buildRelationshipTree();
         $this->applyRelationshipQuery($this->relations);
         $this->reformatQueryComponents();
         $this->query->columns = array_merge($this->getColumns($this->relations), $this->getObserverColumns());
         $this->applySearch();
         $models = $this->buildModelsFromRelationshipTree($this->relations, $results = $this->query->get());
     } else {
         $models = $this->getModels($columns);
     }
     return $this->model->newCollection($models);
 }
开发者ID:fembri,项目名称:eloficient,代码行数:24,代码来源:Builder.php


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