Skip to content

Commit

Permalink
fix pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 25, 2020
1 parent c59cffa commit 5d817be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Pagination/UrlWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function get()
{
$onEachSide = $this->paginator->onEachSide;

if ($this->paginator->lastPage() < ($onEachSide * 2) + 6) {
if ($this->paginator->lastPage() < ($onEachSide * 2) + 8) {
return $this->getSmallSlider();
}

Expand Down
10 changes: 5 additions & 5 deletions tests/Pagination/UrlWindowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public function testPresenterCanGetAUrlRangeForAWindowOfLinks()
* Test Being Near The End Of The List
*/
$array = [];
for ($i = 1; $i <= 13; $i++) {
for ($i = 1; $i <= 20; $i++) {
$array[$i] = 'item'.$i;
}
$p = new LengthAwarePaginator($array, count($array), 1, 10);
$p = new LengthAwarePaginator($array, count($array), 1, 17);
$window = new UrlWindow($p);
$last = [];
for ($i = 4; $i <= 13; $i++) {
for ($i = 11; $i <= 20; $i++) {
$last[$i] = '/?page='.$i;
}
$this->assertEquals(['first' => [1 => '/?page=1', 2 => '/?page=2'], 'slider' => null, 'last' => $last], $window->get());
Expand All @@ -56,7 +56,7 @@ public function testPresenterCanGetAUrlRangeForAWindowOfLinks()
public function testCustomUrlRangeForAWindowOfLinks()
{
$array = [];
for ($i = 1; $i <= 13; $i++) {
for ($i = 1; $i <= 20; $i++) {
$array[$i] = 'item'.$i;
}

Expand All @@ -69,6 +69,6 @@ public function testCustomUrlRangeForAWindowOfLinks()
$slider[$i] = '/?page='.$i;
}

$this->assertEquals(['first' => [1 => '/?page=1', 2 => '/?page=2'], 'slider' => $slider, 'last' => [12 => '/?page=12', 13 => '/?page=13']], $window->get());
$this->assertEquals(['first' => [1 => '/?page=1', 2 => '/?page=2'], 'slider' => $slider, 'last' => [19 => '/?page=19', 20 => '/?page=20']], $window->get());
}
}

0 comments on commit 5d817be

Please sign in to comment.