本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::count方法的具体用法?PHP Model::count怎么用?PHP Model::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::count方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: count
/**
* Retrieve count of records.
*
* @param array $columns
*
* @return mixed
*/
public function count()
{
$this->applyCriteria();
$this->applyScope();
if ($this->model instanceof \Illuminate\Database\Eloquent\Builder) {
$results = $this->model->count();
} else {
$results = $this->model->count();
}
$this->resetModel();
return $results;
}
示例2: rebuildRepository
/**
* Rebuild a specific repository
*
* @param \Illuminate\Database\Eloquent\Model $modelRepository
*
* @return void
*/
public function rebuildRepository(Model $modelRepository)
{
$count = $modelRepository->count();
if ($count < 1) {
return $this->comment(' No available models found.');
}
$progress = new ProgressBar($this->getOutput(), ++$count);
$modelRepository->chunk(200, function ($models) use($progress) {
$this->rebuildModels($models->all(), $progress);
});
$progress->finish();
}
示例3: getByPage
public function getByPage($page = 1, $limit = 10, array $with = array())
{
$result = new StdClass();
$result->page = $page;
$result->limit = $limit;
$result->totalItems = 0;
$result->items = array();
$query = $this->make($with);
$items = $query->skip($limit * ($page - 1))->take($limit)->get();
$result->totalItems = $this->model->count();
$result->items = self::wrap($items);
return $result;
}
示例4: findWhere
/**
* Find data by multiple fields.
*
* @param array $where
* @param array $columns
* @param bool $isCount
*
* @throws RepositoryException
*
* @return mixed
*/
public function findWhere(array $where, array $columns = ['*'], $isCount = false)
{
$this->applyCriteria();
if (!$isCount) {
$this->applyOrder();
}
foreach ($where as $field => $value) {
if (is_array($value)) {
list($field, $condition, $search_value) = $value;
$this->model = $this->model->where($field, $condition, $search_value);
} else {
$this->model = $this->model->ofValue($field, $value);
}
}
if ($isCount) {
$counts = $this->model->count();
} else {
$model = $this->model->get($columns);
}
$this->makeModel();
return $isCount ? $counts : $this->parseResult($model);
}
示例5: count
/**
* Returns the count of all the records.
*
* @return int
*/
public function count()
{
return $this->model->count();
}
示例6: count
/**
* Retrieve the count of row in the table.
*
* @return int
*/
public function count()
{
$results = $this->model->count();
$this->resetModel();
return $results;
}
示例7: getList
/**
* Parses and displays a list
*
* @param \Illuminate\Database\Eloquent\Model $pastes
* @param bool $showFilters
* @param bool $showSearch
* @return \Illuminate\Support\Facades\View
*/
private function getList($pastes, $showSearch = FALSE, $showFilters = FALSE)
{
// Check if no pastes were found
if ($pastes->count() === 0) {
App::abort(418);
// No pastes found
}
// Output the view
$data = array('pastes' => $pastes, 'pages' => $pastes->links(), 'filters' => $showFilters, 'search' => $showSearch and Site::config('general')->pasteSearch);
return View::make('site/list', $data);
}