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

Conversation

ockle
Copy link
Contributor

@ockle ockle commented Jan 13, 2017

When rendering pagination with a custom view:

{!! $users->links('custom-view') !!}

this pull request adds the ability to send data to the view:

{!! $users->links('custom-view', ['foo' => 'bar']) !!}

@GrahamCampbell
Copy link
Member

What's the use case for this please. Why not use view composers?

@ockle
Copy link
Contributor Author

ockle commented Jan 13, 2017

@GrahamCampbell Because view composers don't contain any relation to the context the view is being rendered in.
As I see it, rendering the pagination is akin to including sub-views. They allow extra data to be passed in so that you can e.g. conditionally show HTML/data/etc.
This functionality would be useful in the pagination view so one could e.g. change the arrow character used for the paginaiton next/previous links in different parts of your application. If you currently want to be able to do this, you have to have two almost identical pagination views that are only different by two characters. This is a significant amount of code repetition.
There is also a suggestion of a convention in the framework that when you specify a view name, the next parameter is data to be passed to the view, so to me, this functionality is one of those rare times in Laravel where you expect something to work the way you are used to but doesn't, so this PR increases consistency in that regard.

@Francismori7
Copy link
Contributor

Also might find usage for this by using ['minimalist' => true] which could, in your custom template, prevent some stuff from being outputted.

@taylorotwell taylorotwell merged commit 925a4ac into laravel:5.4 Jan 15, 2017
@tillkruss
Copy link
Contributor

Can you add this to the docs, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants