diff --git a/src/Illuminate/Foundation/changes.json b/src/Illuminate/Foundation/changes.json index 0861f39b2613..4c997f30de47 100755 --- a/src/Illuminate/Foundation/changes.json +++ b/src/Illuminate/Foundation/changes.json @@ -31,7 +31,8 @@ {"message": "Added App::middleware method to inject middlewares onto Stack.", "backport": null}, {"message": "Deprecate 'close' application hooks, Stack middlewares should be used instead.", "backport": null}, {"message": "A new packages directory within `lang` can now override package language files.", "backport": null}, - {"message": "Added new 'Auth::viaRemember method to determine if user was authed via 'remember me' cookie.", "backport": null} + {"message": "Added new 'Auth::viaRemember method to determine if user was authed via 'remember me' cookie.", "backport": null}, + {"message": "Allow passing a view name to paginator's 'links' method.", "backport": null} ], "4.0.x": [ {"message": "Added implode method to query builder and Collection class.", "backport": null}, diff --git a/src/Illuminate/Pagination/Environment.php b/src/Illuminate/Pagination/Environment.php index 57b2eeacce11..9f3cf1e8860a 100755 --- a/src/Illuminate/Pagination/Environment.php +++ b/src/Illuminate/Pagination/Environment.php @@ -109,13 +109,14 @@ public function make(array $items, $total, $perPage) * Get the pagination view. * * @param \Illuminate\Pagination\Paginator $paginator + * @param string $view * @return \Illuminate\View\View */ - public function getPaginationView(Paginator $paginator) + public function getPaginationView(Paginator $paginator, $view = null) { $data = array('environment' => $this, 'paginator' => $paginator); - return $this->view->make($this->getViewName(), $data); + return $this->view->make($this->getViewName($view), $data); } /** @@ -191,10 +192,13 @@ public function getPageName() /** * Get the name of the pagination view. * + * @param string $view * @return string */ - public function getViewName() + public function getViewName($view = null) { + if ( ! is_null($view)) return $view; + return $this->viewName ?: 'pagination::slider'; } diff --git a/src/Illuminate/Pagination/Paginator.php b/src/Illuminate/Pagination/Paginator.php index 3f9b8b23e4ca..68e89071abbd 100755 --- a/src/Illuminate/Pagination/Paginator.php +++ b/src/Illuminate/Pagination/Paginator.php @@ -163,11 +163,12 @@ protected function isValidPageNumber($page) /** * Get the pagination links view. * + * @param string $view * @return \Illuminate\View\View */ - public function links() + public function links($view = null) { - return $this->env->getPaginationView($this); + return $this->env->getPaginationView($this, $view); } /** @@ -440,7 +441,7 @@ public function offsetUnset($key) public function toArray() { return array( - 'total' => $this->total, 'per_page' => $this->perPage, + 'total' => $this->total, 'per_page' => $this->perPage, 'current_page' => $this->currentPage, 'last_page' => $this->lastPage, 'from' => $this->from, 'to' => $this->to, 'data' => $this->getCollection()->toArray(), ); diff --git a/tests/Pagination/PaginationPaginatorTest.php b/tests/Pagination/PaginationPaginatorTest.php index 61cacb4eb4dc..21a0602ff796 100755 --- a/tests/Pagination/PaginationPaginatorTest.php +++ b/tests/Pagination/PaginationPaginatorTest.php @@ -91,7 +91,7 @@ public function testPaginationContextHandlesPageMissing() public function testGetLinksCallsEnvironmentProperly() { $p = new Paginator($env = m::mock('Illuminate\Pagination\Environment'), array('foo', 'bar', 'baz'), 3, 2); - $env->shouldReceive('getPaginationView')->once()->with($p)->andReturn('foo'); + $env->shouldReceive('getPaginationView')->once()->with($p, null)->andReturn('foo'); $this->assertEquals('foo', $p->links()); }