Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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();
 }
 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;
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
 /**
  * Returns the count of all the records.
  *
  * @return int
  */
 public function count()
 {
     return $this->model->count();
 }
Ejemplo n.º 6
0
 /**
  * Retrieve the count of row in the table.
  *
  * @return int
  */
 public function count()
 {
     $results = $this->model->count();
     $this->resetModel();
     return $results;
 }
Ejemplo n.º 7
0
 /**
  * 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);
 }