Skip to content

Commit

Permalink
Merge pull request #545 from mguariero/master
Browse files Browse the repository at this point in the history
Added method that makes the count of the records without the need to …
  • Loading branch information
eullercdr authored Aug 30, 2019
2 parents dcb7b8c + e19f1a3 commit 1bd3935
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Prettus/Repository/Eloquent/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,31 @@ public function all($columns = ['*'])
return $this->parserResult($results);
}

/**
* Count results of repository
*
* @param array $where
* @param string $columns
*
* @return int
*/
public function count(array $where = [], $columns = '*')
{
$this->applyCriteria();
$this->applyScope();

if($where) {
$this->applyConditions($where);
}

$result = $this->model->count($columns);

$this->resetModel();
$this->resetScope();

return $result;
}

/**
* Alias of All method
*
Expand Down

0 comments on commit 1bd3935

Please sign in to comment.