-
-
Notifications
You must be signed in to change notification settings - Fork 554
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.x] Add support for $view
parameter closure with Route::statamic()
#11452
Conversation
…if we’re not handling it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I'd want to change is to make sure if you use Request $request
as the first argument of the closure that it'd work too, like a regular route.
Route::statamic('foo/{bar}', function ($bar) {
return view('myview', ['bar' => $bar];
});
Route::statamic('foo/{bar}', function (Request $request, $bar) {
return view('myview', ['bar' => $bar];
});
(Maybe it already does work, but a test to show it would be good.)
…not just `Request $request`.
@jasonvarga After some further testing, technically Also, Laravel supports and documents type-hinted service-container-friendly dependency injection in general. I figured we might as well go for feature parity with Route::statamic('example/{one}', function ($one, Request $request, Joe $joe) {
ray($one, $request, $joe);
}); |
$view
parameter closure with Statamic::route()
$view
parameter closure with Route::statamic()
This PR adds support for optional
$view
parameter closure withStatamic::route()
, so that you can dynamically render a view from a route segment.For example, this works fine in Laravel...
So this should work with Statamic routes as well...
This PR makes it work like this...
TODO
$view
parameter$data
parameterview($template, $data)
in Laravel, it's expected you'll pass your dynamic data directly into that 👍References #9953