Skip to content

Commit 39a5c38

Browse files
authored
Revert "[10.x] allow override of the Builder paginate() total (#46336)" (#46406)
This reverts commit df0135b.
1 parent 8427a4c commit 39a5c38

File tree

3 files changed

+4
-30
lines changed

3 files changed

+4
-30
lines changed

src/Illuminate/Database/Eloquent/Builder.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -889,16 +889,15 @@ public function pluck($column, $key = null)
889889
* @param array|string $columns
890890
* @param string $pageName
891891
* @param int|null $page
892-
* @param \Closure|int|null $total
893892
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
894893
*
895894
* @throws \InvalidArgumentException
896895
*/
897-
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null, $total = null)
896+
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
898897
{
899898
$page = $page ?: Paginator::resolveCurrentPage($pageName);
900899

901-
$total = value($total) ?? $this->toBase()->getCountForPagination();
900+
$total = $this->toBase()->getCountForPagination();
902901

903902
$perPage = ($perPage instanceof Closure
904903
? $perPage($total)

src/Illuminate/Database/Query/Builder.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,14 +2727,13 @@ protected function runSelect()
27272727
* @param array|string $columns
27282728
* @param string $pageName
27292729
* @param int|null $page
2730-
* @param \Closure|int|null $total
27312730
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
27322731
*/
2733-
public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null, $total = null)
2732+
public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null)
27342733
{
27352734
$page = $page ?: Paginator::resolveCurrentPage($pageName);
27362735

2737-
$total = value($total) ?? $this->getCountForPagination();
2736+
$total = $this->getCountForPagination();
27382737

27392738
$perPage = $perPage instanceof Closure ? $perPage($total) : $perPage;
27402739

tests/Database/DatabaseQueryBuilderTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4450,30 +4450,6 @@ public function testPaginateWithSpecificColumns()
44504450
]), $result);
44514451
}
44524452

4453-
public function testPaginateWithTotalOverride()
4454-
{
4455-
$perPage = 16;
4456-
$columns = ['id', 'name'];
4457-
$pageName = 'page-name';
4458-
$page = 1;
4459-
$builder = $this->getMockQueryBuilder();
4460-
$path = 'http://foo.bar?page=3';
4461-
4462-
$results = collect([['id' => 3, 'name' => 'Taylor'], ['id' => 5, 'name' => 'Mohamed']]);
4463-
4464-
$builder->shouldReceive('getCountForPagination')->never();
4465-
$builder->shouldReceive('forPage')->once()->with($page, $perPage)->andReturnSelf();
4466-
$builder->shouldReceive('get')->once()->andReturn($results);
4467-
4468-
Paginator::currentPathResolver(function () use ($path) {
4469-
return $path;
4470-
});
4471-
4472-
$result = $builder->paginate($perPage, $columns, $pageName, $page, 10);
4473-
4474-
$this->assertEquals(10, $result->total());
4475-
}
4476-
44774453
public function testCursorPaginate()
44784454
{
44794455
$perPage = 16;

0 commit comments

Comments
 (0)