本文整理汇总了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();
}
示例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.');
}
示例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;
}
示例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));
}
示例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;
}
}
示例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;
}
示例7: getEntities
/**
* @return \ArrayIterator|mixed|null
*/
public function getEntities()
{
$result = $this->specificationQuery->get();
if (0 === $result->count()) {
return null;
}
return $this->mapper->fromDbTableRows($result);
}
示例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;
}
示例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()));
}
示例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;
}
示例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;
}
}
示例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;
});
}
示例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;
}
示例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);
}
示例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);
}