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.5] Add Route::view() helper #19835

Merged
merged 4 commits into from Jul 2, 2017

Conversation

Projects
None yet
6 participants
@brayniverse
Contributor

brayniverse commented Jun 29, 2017

This adds a new Route::view() method. The implementation works with route caching as it uses an internal ViewController class.

Route::view('contact', 'pages.contact');

The first argument is the route and the second is the view name.

@brayniverse brayniverse changed the title from Add Route::view() helper to [5.5] Add Route::view() helper Jun 30, 2017

/**
* Create a new view controller instance.
*
* @param \Illuminate\Contracts\View\Factory $view

This comment has been minimized.

@lucasmichot

lucasmichot Jun 30, 2017

Contributor

Missing @return void

@lucasmichot

lucasmichot Jun 30, 2017

Contributor

Missing @return void

This comment has been minimized.

@brayniverse

brayniverse Jun 30, 2017

Contributor

Thanks.

@brayniverse

brayniverse Jun 30, 2017

Contributor

Thanks.

@lucasmichot

This comment has been minimized.

Show comment
Hide comment
@lucasmichot

lucasmichot Jun 30, 2017

Contributor

It would be more useful if we could also pass variables:
Route::view('contact', 'pages.contact', ['foo' => 'bar']);

Contributor

lucasmichot commented Jun 30, 2017

It would be more useful if we could also pass variables:
Route::view('contact', 'pages.contact', ['foo' => 'bar']);

@fitztrev

This comment has been minimized.

Show comment
Hide comment
@fitztrev

fitztrev Jun 30, 2017

Contributor

It would be more useful if we could also pass variables:
Route::view('contact', 'pages.contact', ['foo' => 'bar']);

What variables would you have in a route file? I think a view composer would be better if you need to do something like that.

Contributor

fitztrev commented Jun 30, 2017

It would be more useful if we could also pass variables:
Route::view('contact', 'pages.contact', ['foo' => 'bar']);

What variables would you have in a route file? I think a view composer would be better if you need to do something like that.

@lucasmichot

This comment has been minimized.

Show comment
Hide comment
@lucasmichot

lucasmichot Jun 30, 2017

Contributor
Route::view('contact/germany', 'pages.contact', ['office' => 'Berlin'])->name('contact.germany');
Route::view('contact/england', 'pages.contact', ['office' => 'London'])->name('contact.england');

The goal of this PR is too make Route::view a fast shortcut to use, if you have to create a view composer to use it, because you cannot pass any variable, you lose a bit the benefit of it

Contributor

lucasmichot commented Jun 30, 2017

Route::view('contact/germany', 'pages.contact', ['office' => 'Berlin'])->name('contact.germany');
Route::view('contact/england', 'pages.contact', ['office' => 'London'])->name('contact.england');

The goal of this PR is too make Route::view a fast shortcut to use, if you have to create a view composer to use it, because you cannot pass any variable, you lose a bit the benefit of it

@brayniverse

This comment has been minimized.

Show comment
Hide comment
@brayniverse

brayniverse Jun 30, 2017

Contributor

Interesting point, I hadn't considered that. If this works with route caching I don't see a problem with adding it. It would be a fairly simple change too.

@taylorotwell do you have any strong opinions on this?

Contributor

brayniverse commented Jun 30, 2017

Interesting point, I hadn't considered that. If this works with route caching I don't see a problem with adding it. It would be a fairly simple change too.

@taylorotwell do you have any strong opinions on this?

@taylorotwell

This comment has been minimized.

Show comment
Hide comment
@taylorotwell

taylorotwell Jun 30, 2017

Member

Fine with me.

Member

taylorotwell commented Jun 30, 2017

Fine with me.

@joshmanders

This comment has been minimized.

Show comment
Hide comment
@joshmanders

joshmanders Jun 30, 2017

Contributor

Welp there goes my render helper I make for every projects! haha. Thanks for this PR @brayniverse

Contributor

joshmanders commented Jun 30, 2017

Welp there goes my render helper I make for every projects! haha. Thanks for this PR @brayniverse

@taylorotwell

This comment has been minimized.

Show comment
Hide comment
@taylorotwell

taylorotwell Jun 30, 2017

Member

@brayniverse are you going to implement the data handling?

Member

taylorotwell commented Jun 30, 2017

@brayniverse are you going to implement the data handling?

@brayniverse

This comment has been minimized.

Show comment
Hide comment
@brayniverse

brayniverse Jun 30, 2017

Contributor

Yes I will do. I've been driving all evening and the cars packed in. So I'll do it as soon as I get a chance but it probably won't be tonight.

Contributor

brayniverse commented Jun 30, 2017

Yes I will do. I've been driving all evening and the cars packed in. So I'll do it as soon as I get a chance but it probably won't be tonight.

@vlakoff

This comment has been minimized.

Show comment
Hide comment
@vlakoff

vlakoff Jun 30, 2017

Contributor

@joshmanders That's the kind of helper probably a lot of people had added in their projects ;-)

Contributor

vlakoff commented Jun 30, 2017

@joshmanders That's the kind of helper probably a lot of people had added in their projects ;-)

@brayniverse

This comment has been minimized.

Show comment
Hide comment
@brayniverse

brayniverse Jul 1, 2017

Contributor

All should be good now. Data can be passed to the view and I tested it still works with route caching.

Contributor

brayniverse commented Jul 1, 2017

All should be good now. Data can be passed to the view and I tested it still works with route caching.

@taylorotwell taylorotwell merged commit 03ef55a into laravel:master Jul 2, 2017

2 checks passed

continuous-integration/styleci/pr The StyleCI analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment