codezero-be / laravel-localized-routes

⭐️ A convenient way to set up and use localized routes in a Laravel app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call to a member function getAction() on null

vincent-tarrit opened this issue · comments

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 !

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

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.

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"
        ]

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

No worries, glad it works :)