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