-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Ability to chain the root view #280
Conversation
Hey @MarGul, Thanks for this! I do dig the idea, although the only thing I somewhat dislike is that:
Which makes me wonder whether we should (in addition to this change) add an 'alias' method that we could use for this? In either case, I'm definitely OK with these changes even if we don't find a great/better solution to that, so I'll just approve it for now as-is. @reinink thoughts? |
@claudiodekker agree that the name |
Hmm, my primary concern with this change is that $authResponse = Inertia::render('Auth/Home');
$guestResponse = Inertia::setRootView('guest')->render('Guest/Home');
if (Auth::user()) {
return $authResponse; // will use "guest" root view
} Obviously this is silly code, but it illustrates that someone could inadvertently change the root view globally without realizing it. The better way to solve this is not in the return Inertia::render('Guest/Home')->rootView('guest'); Feel free to update this PR accordingly. 👍 |
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.
Add rootView()
to the Response
class instead, as per this comment.
This was a way better solution @reinink ! I have pushed the code now and tried it out. Works perfect for me now because I have one rootView for my |
@MarGul Awesome, thanks! |
This has been released: https://github.com/inertiajs/inertia-laravel/releases/tag/v0.4.4 (I still need to write the release notes) |
@reinink Maybe for 1.0 it could be called Nice feature for sure 🙌 |
@dillingham Hmm, not sure about that, since it's not a layout, it's a root view. I'd prefer to save the word "layout" for client-side layouts (https://inertiajs.com/pages#creating-layouts). |
Very small change and mostly syntax-sugar.
I have a guest section of my app where I need a new root-view.
Instead of doing
I can now do this instead:
return Inertia::setRootView('guest')->render('Guest/Home');
Nothing much but I like it this way instead. What do you say?