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