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

[5.4] Fixing Model Binding when you have a Route Binding with same name #18476

Merged
merged 1 commit into from
Mar 24, 2017

Conversation

dbpolito
Copy link
Contributor

When you have a Route Binding with the same compound name of the Model Binding, it colides, for example:

Route::model('foo_bar', FooBarModel::class);
Route::resource('foo-bar', FooBarController::class);

class FooBarController extends Controller {
    public function show(FooBarModel $fooBar) {
    }
}

This happens because at https://github.com/laravel/framework/blob/5.4/src/Illuminate/Routing/ImplicitRouteBinding.php#L21 the parameter is called fooBar and isn't found, but bellow at https://github.com/laravel/framework/blob/5.4/src/Illuminate/Routing/ImplicitRouteBinding.php#L27 it changes the parameter name to foo_bar and at https://github.com/laravel/framework/blob/5.4/src/Illuminate/Routing/ImplicitRouteBinding.php#L32 the parameter value is already a FooBarModel.

The use case is pretty specific, Route and Model Binding with same name AND compound name.

My PR fixes this problem.

@taylorotwell
Copy link
Member

Can you describe what you mean by "collide". What error occurs?

@taylorotwell taylorotwell merged commit 5eb2e6c into laravel:5.4 Mar 24, 2017
@taylorotwell
Copy link
Member

Nevermind I recreated it. Thanks.

@GrahamCampbell GrahamCampbell changed the title Fixing Model Binding when you have a Route Binding with same name [5.4] Fixing Model Binding when you have a Route Binding with same name Mar 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants