Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "kalnoy/nestedset",
"name": "sozidatel79/nestedset",
"description": "Nested Set Model for Laravel 4-5",
"keywords": ["laravel", "nested sets", "nsm", "database", "hierarchy"],
"license": "MIT",
Expand Down
24 changes: 24 additions & 0 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Support\Arr;
use LogicException;
use Illuminate\Database\Query\Expression;
use Illuminate\Pagination\Paginator;

class QueryBuilder extends Builder
{
Expand Down Expand Up @@ -1085,4 +1086,27 @@ public function root(array $columns = ['*'])
{
return $this->whereIsRoot()->first($columns);
}

/**
* @param null $perPage
* @param array $columns
* @param string $pageName
* @param null $page
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Pagination\LengthAwarePaginator
*/
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$page = $page ?: Paginator::resolveCurrentPage($pageName);

$perPage = $perPage ?: $this->model->getPerPage();

$results = ($total = $this->toBase()->getCountForPagination())
? $this->forPage($page, $perPage)->get($columns)
: $this->model->newCollection();

return $this->paginator($results, $total, $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]);
}
}