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


PHP Model::count方法代码示例

本文整理汇总了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;
 }
开发者ID:LavaLite,项目名称:framework,代码行数:19,代码来源:BaseRepository.php

示例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();
 }
开发者ID:irto,项目名称:solrio,代码行数:19,代码来源:RebuildCommand.php

示例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;
 }
开发者ID:geomagilles,项目名称:eloquent-repository,代码行数:13,代码来源:EloquentRepository.php

示例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);
 }
开发者ID:sjfinder,项目名称:repository,代码行数:33,代码来源:BaseRepository.php

示例5: count

 /**
  * Returns the count of all the records.
  *
  * @return int
  */
 public function count()
 {
     return $this->model->count();
 }
开发者ID:vinelab,项目名称:lucid,代码行数:9,代码来源:Repository.php

示例6: count

 /**
  * Retrieve the count of row in the table.
  *
  * @return int
  */
 public function count()
 {
     $results = $this->model->count();
     $this->resetModel();
     return $results;
 }
开发者ID:Jastkast,项目名称:Page,代码行数:11,代码来源:BaseRepository.php

示例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);
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:19,代码来源:ListController.php


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