-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDbPaginator.php
39 lines (36 loc) · 959 Bytes
/
DbPaginator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* Arikaim
*
* @link http://www.arikaim.com
* @copyright Copyright (c) Konstantin Atanasov <[email protected]>
* @license http://www.arikaim.com/license
*
*/
namespace Arikaim\Core\Paginator;
use Arikaim\Core\Paginator\PaginatorInterface;
use Arikaim\Core\Paginator\Paginator;
/**
* Paginate Illuminate\Database\Eloquent\Builder objects
*/
class DbPaginator extends Paginator implements PaginatorInterface
{
/**
* Constructor
*
* @param Builder $builder
* @param integer $page
* @param integer $perPage
*/
public function __construct($builder, int $page = 1, int $perPage = Paginator::DEFAULT_PER_PAGE)
{
$total = $builder->toBase()->getCountForPagination();
parent::__construct(
$page,
$total ? $builder->forPage($page,$perPage)->get(['*']) : [],
$perPage,
null,
$total
);
}
}