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

[11.x] Fixes route model binding when additional non reflected parameters are present #52261

Closed
wants to merge 2 commits into from

Conversation

jimmyaldape
Copy link

Resolves #52253

This PR fixes the issue where additional parameters that are non reflected are present causing route model binding to fail.

In the example provided in #52253, this now works as expected. {subdomain} is now filtered out and route model binding can proceed as usual.

Route::domain('{subdomain}.' . config('app.url'))->group(function() {
    Route::get('/', function() {
        $organisation = Organisation::findOrFail(Context::get('organisation'));
        return $organisation->name;
    });

    Route::resource('people', PersonController::class);
});

In addition subsequent route model bindings work. For example the following all resolve accordingly:

Route::domain('{subdomain}.' . config('app.url'))->group(function() {
    ...

    Route::get('/user/{id}/post/{post}', function (string $id, string $post) {
        return "User: $id, Post: $post";
    });
});

@@ -73,7 +78,7 @@ public function resolveMethodDependencies(array $parameters, ReflectionFunctionA
protected function transformDependency(ReflectionParameter $parameter, $parameters, $skippableValue)
{
$className = Reflector::getParameterClassName($parameter);

dd($className);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be causing tests to fail

@jimmyaldape
Copy link
Author

Seems there is more to consider, will pull to draft for now

@driesvints
Copy link
Member

The current behaviour is the expected behaviour. The subdomain param is always passed to the controller method.

@driesvints driesvints closed this Jul 25, 2024
@jimmyaldape jimmyaldape deleted the ja/fix-52253 branch July 25, 2024 13:31
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.

Route model binding fails when additional route parameters are present
3 participants