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

Dash in a resource route name breaks Route Model binding #12

Open
butcherman opened this issue Nov 26, 2022 · 3 comments
Open

Dash in a resource route name breaks Route Model binding #12

butcherman opened this issue Nov 26, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@butcherman
Copy link

Describe the bug
When I have a resource route that has a dash in the name, route/model binding gets broken and an error "Missing required parameter for [Route....]"

What version does this affect?

  • Laravel Version: 9.38
  • Package Version: 1.6.0

To Reproduce
Setup a simple Resource Controller using Resource Breadcrumbs. Ex:
Route::resource('some-route', SomeRouteController::class)->breadcrumbs(function(ResourceBreadcrumbs $breadcrumbs) {
$breadcrumbs->index('Index Rte')->show('Show Rte')->edit('Edit Rte');
}

When trying to visit the Edit or Show routes and you will get the missing required parameter error.
Changing the - to an underscore will correct the error. Separating the resource route into individual routes will also correct the error.

Expected behavior
I use dashes in my route names on a regular basis as they are easy to read and match up with Laravel's slug method

@butcherman butcherman added the bug Something isn't working label Nov 26, 2022
@raphaelbeckmann
Copy link

I have the same problem. I also found out that Gretel is converting the kebab case resource identifier ("some-route") to snake case in the model identifier variable ($some_route) instead of camel case ($someRoute). That should be fixed as well.

@inxilpro
Copy link
Contributor

Can you explain why this test doesn't cover the case you're describing?

@butcherman
Copy link
Author

In the test you provided, you are using Route Model Binding. In my examples I am not. In my use case, I use it where I can, but in this case I search for the model based on if the user input a slug (string) or the ID (int) of the model. I need to search two columns so Route Model Binding does not work well for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants