Skip to content

Commit

Permalink
allow data to be passed to the view when using a custom view in a pag…
Browse files Browse the repository at this point in the history
…inator (#17331)
  • Loading branch information
ockle authored and taylorotwell committed Jan 15, 2017
1 parent 3097f59 commit 925a4ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Contracts/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public function isEmpty();
* Render the paginator using a given view.
*
* @param string|null $view
* @param array $data
* @return string
*/
public function render($view = null);
public function render($view = null, $data = []);
}
12 changes: 7 additions & 5 deletions src/Illuminate/Pagination/LengthAwarePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,27 @@ protected function setCurrentPage($currentPage, $pageName)
* Render the paginator using the given view.
*
* @param string $view
* @param array $data
* @return string
*/
public function links($view = null)
public function links($view = null, $data = [])
{
return $this->render($view);
return $this->render($view, $data);
}

/**
* Render the paginator using the given view.
*
* @param string $view
* @param array $data
* @return string
*/
public function render($view = null)
public function render($view = null, $data = [])
{
return new HtmlString(static::viewFactory()->make($view ?: static::$defaultView, [
return new HtmlString(static::viewFactory()->make($view ?: static::$defaultView, array_merge($data, [
'paginator' => $this,
'elements' => $this->elements(),
])->render());
]))->render());
}

/**
Expand Down
12 changes: 7 additions & 5 deletions src/Illuminate/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,27 @@ public function nextPageUrl()
* Render the paginator using the given view.
*
* @param string|null $view
* @param array $data
* @return string
*/
public function links($view = null)
public function links($view = null, $data = [])
{
return $this->render($view);
return $this->render($view, $data);
}

/**
* Render the paginator using the given view.
*
* @param string|null $view
* @param array $data
* @return string
*/
public function render($view = null)
public function render($view = null, $data = [])
{
return new HtmlString(
static::viewFactory()->make($view ?: static::$defaultSimpleView, [
static::viewFactory()->make($view ?: static::$defaultSimpleView, array_merge($data, [
'paginator' => $this,
])->render()
]))->render()
);
}

Expand Down

0 comments on commit 925a4ac

Please sign in to comment.