Skip to content
Merged
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 ci/convergence-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ eloquent_lists=6
macroable_trait=12
softdeleting_trait=2
legacy_contracts=37
pagination_getters=15
pagination_getters=10
route_filters=4
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function paginate($perPage = null, $columns = array('*'))
// from the database since this isn't performed by the Eloquent builder.
$pager = $this->query->paginate($perPage, $columns);

$this->hydratePivotRelation($pager->getItems());
$this->hydratePivotRelation($pager->items());

return $pager;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Illuminate/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function isQuickPaginating()
* @param int|null $total
* @return int
*/
public function getCurrentPage($total = null)
public function currentPage($total = null)
{
if (is_null($total))
{
Expand All @@ -333,7 +333,7 @@ public function getCurrentPage($total = null)
*
* @return int
*/
public function getLastPage()
public function lastPage()
{
return $this->lastPage;
}
Expand All @@ -343,7 +343,7 @@ public function getLastPage()
*
* @return int
*/
public function getFrom()
public function firstItem()
{
return $this->from;
}
Expand All @@ -353,7 +353,7 @@ public function getFrom()
*
* @return int
*/
public function getTo()
public function lastItem()
{
return $this->to;
}
Expand All @@ -363,7 +363,7 @@ public function getTo()
*
* @return int
*/
public function getPerPage()
public function perPage()
{
return $this->perPage;
}
Expand All @@ -383,7 +383,7 @@ public function getCollection()
*
* @return array
*/
public function getItems()
public function items()
{
return $this->items;
}
Expand All @@ -404,7 +404,7 @@ public function setItems($items)
*
* @return int
*/
public function getTotal()
public function total()
{
return $this->total;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Pagination/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ abstract class Presenter {
public function __construct(Paginator $paginator)
{
$this->paginator = $paginator;
$this->lastPage = $this->paginator->getLastPage();
$this->currentPage = $this->paginator->getCurrentPage();
$this->lastPage = $this->paginator->lastPage();
$this->currentPage = $this->paginator->currentPage();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Pagination/views/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$trans = $environment->getTranslator();
?>

<?php if ($paginator->getLastPage() > 1): ?>
<?php if ($paginator->lastPage() > 1): ?>
<ul class="pager">
<?php
echo $presenter->getPrevious($trans->trans('pagination.previous'));
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Pagination/views/slider-3.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$presenter = new Illuminate\Pagination\BootstrapPresenter($paginator);
?>

<?php if ($paginator->getLastPage() > 1): ?>
<?php if ($paginator->lastPage() > 1): ?>
<ul class="pagination">
<?php echo $presenter->render(); ?>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Pagination/views/slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$presenter = new Illuminate\Pagination\BootstrapPresenter($paginator);
?>

<?php if ($paginator->getLastPage() > 1): ?>
<?php if ($paginator->lastPage() > 1): ?>
<div class="pagination">
<ul>
<?php echo $presenter->render(); ?>
Expand Down
4 changes: 2 additions & 2 deletions tests/Pagination/PaginationBootstrapPresenterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ protected function getPresenter()
protected function getPaginator()
{
$paginator = m::mock(Paginator::class);
$paginator->shouldReceive('getLastPage')->once()->andReturn(2);
$paginator->shouldReceive('getCurrentPage')->once()->andReturn(1);
$paginator->shouldReceive('lastPage')->once()->andReturn(2);
$paginator->shouldReceive('currentPage')->once()->andReturn(1);
$paginator->shouldReceive('getUrl')->andReturnUsing(function($page) { return 'http://foo.com?page='.$page; });
return $paginator;
}
Expand Down
48 changes: 24 additions & 24 deletions tests/Pagination/PaginationPaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function testPaginationContextIsSetupCorrectly()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(1);
$p->setupPaginationContext();

$this->assertEquals(2, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertEquals(2, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
}


Expand All @@ -31,8 +31,8 @@ public function testPaginationContextIsSetupCorrectlyWithEmptyItems()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(1);
$p->setupPaginationContext();

$this->assertEquals(1, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertEquals(1, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
}


Expand All @@ -42,9 +42,9 @@ public function testSimplePagination()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(1);
$p->setupPaginationContext();

$this->assertEquals(2, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertEquals(['foo', 'bar'], $p->getItems());
$this->assertEquals(2, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
$this->assertEquals(['foo', 'bar'], $p->items());
}


Expand All @@ -54,9 +54,9 @@ public function testSimplePaginationLastPage()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(1);
$p->setupPaginationContext();

$this->assertEquals(1, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertCount(3, $p->getItems());
$this->assertEquals(1, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
$this->assertCount(3, $p->items());
}


Expand All @@ -66,8 +66,8 @@ public function testPaginationContextIsSetupCorrectlyInCursorMode()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(1);
$p->setupPaginationContext();

$this->assertEquals(2, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertEquals(2, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
}


Expand All @@ -77,8 +77,8 @@ public function testPaginationContextSetsUpRangeCorrectly()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(1);
$p->setupPaginationContext();

$this->assertEquals(1, $p->getFrom());
$this->assertEquals(2, $p->getTo());
$this->assertEquals(1, $p->firstItem());
$this->assertEquals(2, $p->lastItem());
}


Expand All @@ -88,8 +88,8 @@ public function testPaginationContextHandlesHugeCurrentPage()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(15);
$p->setupPaginationContext();

$this->assertEquals(2, $p->getLastPage());
$this->assertEquals(2, $p->getCurrentPage());
$this->assertEquals(2, $p->lastPage());
$this->assertEquals(2, $p->currentPage());
}


Expand All @@ -99,8 +99,8 @@ public function testPaginationContextHandlesPageLessThanOne()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(-1);
$p->setupPaginationContext();

$this->assertEquals(2, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertEquals(2, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
}


Expand All @@ -110,8 +110,8 @@ public function testPaginationContextHandlesPageLessThanOneAsString()
$factory->shouldReceive('getCurrentPage')->once()->andReturn('-1');
$p->setupPaginationContext();

$this->assertEquals(2, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertEquals(2, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
}


Expand All @@ -121,8 +121,8 @@ public function testPaginationContextHandlesPageInvalidFormat()
$factory->shouldReceive('getCurrentPage')->once()->andReturn('abc');
$p->setupPaginationContext();

$this->assertEquals(2, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertEquals(2, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
}


Expand All @@ -132,8 +132,8 @@ public function testPaginationContextHandlesPageMissing()
$factory->shouldReceive('getCurrentPage')->once()->andReturn(null);
$p->setupPaginationContext();

$this->assertEquals(2, $p->getLastPage());
$this->assertEquals(1, $p->getCurrentPage());
$this->assertEquals(2, $p->lastPage());
$this->assertEquals(1, $p->currentPage());
}


Expand Down
Loading