codezero-be / laravel-localized-routes

⭐️ A convenient way to set up and use localized routes in a Laravel app.
MIT License
504 stars 46 forks source link

Call to a member function getAction() on null #96

Closed vincent-tarrit closed 1 year ago

vincent-tarrit commented 1 year ago

Hello, I have issue that my $request->route() is null in the file Middleware/Detectors/ RouteActionDetector.php:36

Could you help me ?

Thank you very much !

vincent-tarrit commented 1 year ago

To add details, the Route::localized is not recognized by PhpStorm...

ivanvermeyen commented 1 year ago

Hello,

Thanks for reporting the issue. This is probably caused by this line of code.

However, I can't reproduce the issue in a test. Does it fail on a specific route?

Edit: When hitting a regular or fallback route, there should always be a Route instance in the request as far as I know. Only when a 404 is thrown will there be no Route instance , because no route is registered for the URL. But middleware wil not run on a 404, so I don't know how this can happen.

ivanvermeyen commented 1 year ago

To add details, the Route::localized is not recognized by PhpStorm...

PhpStorm should autocomplete this if you use https://github.com/barryvdh/laravel-ide-helper.

Scherm­afbeelding 2023-05-18 om 12 51 13

I have this in my scripts section of composer.json:


        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "@php artisan ide-helper:generate",
            "@php artisan ide-helper:meta"
        ]
vincent-tarrit commented 1 year ago

Hello, sorry ... I was not very wake up... I put the middleware in wrong array oups... everything works perfectly! Thank you !

ivanvermeyen commented 1 year ago

No worries, glad it works :)