Help or new feature to pass parameters to Route when using callables #44839
Unanswered
sezginriggs
asked this question in
Q&A
Replies: 1 comment
-
Could you tell me please what is your purpose exactly? Because I told you about localization in stack overflow. But maybe I can help you if I know what are you trying to do. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I was using old type of (string syntax) Route declarations and I was able to pass "action" parameters and then later in controller, I was able to get it with
$request->route()->getAction();
. But with new "callable syntax" declarations. I cannot do that and sometimes we may need it for various scenarios.My old declaration is below and here I pass "language" as action.
but when trying following "callable" syntax, I couldn't find a way to pass language.
Route::get('/', [PageController::class, 'showHomepage']);
For localization, it may not seem as the best practice but it's something required for some projects. Here you may suggest using this
Route::get('/{language}', [PageController::class, 'showHomepage']);
so we can take $language in controller method and set language according to it.
But when there are other routes like following ones, it becomes something interfering. "Is it homepage route with language code or is it artist route from root path?". And there are also some other situations like that too.
So the new callable syntax needs some way to pass custom parameters to controller methods. If there is a way already, I couldn't find it and I'll appreciate your helps.
Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions