-
Notifications
You must be signed in to change notification settings - Fork 371
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
Make explicit binding for products conditional in hub context #1312
Make explicit binding for products conditional in hub context #1312
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Thanks @theimerj and while I can see there is an issue here I don't think this is correct, when doing some initial testing and editing a product, $route->getPrefix()
returns hub/products/{product}
so the condition wouldn't match.
I think we'd need a more standard approach to determine whether it's a hub request, not just by going off the configured hub path. 🤔
Check if its using the hub middleware? |
@theimerj could you retarget the |
Hey @glennjacobs, I retargeted to If you know about some better way how to determine that the route belongs to hub scope, let me know, i will update the code accordingly. |
While developing lunar-api, specifically implementing the possibility of using hashids, I came across an issue with explicit model binding for products.
The underlying packages encodes and decodes route keys on runtime. The login can be seen here. When
AdminHubServiceProvider
binds theproduct
explicitly, the route key does not get decoded.It is also quite difficult to overwrite such binding by other packages. You would have to ensure that the order of service providers is correct in order to "rebind" the routes.
These are the problematic lines:
lunar/packages/admin/src/AdminHubServiceProvider.php
Lines 221 to 223 in d7b6eac
I came up with a simple solution for now:
https://github.com/dystcz/lunar/blob/9eba7aa9e45f19d6d08c8a08f7f55656df213666/packages/admin/src/AdminHubServiceProvider.php#L221-L227
This applies the binding only for routes with hub prefix.
Another solutions would be to implement the binding via middleware or by overwriting the
resolveRouteBinding
method on the model.