Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Ability to pass data to the view when rendering a paginator #17331

Merged
merged 1 commit into from
Jan 15, 2017
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
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