-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
Route Translation with Model Binding not working #268
Comments
This should translate current URL completely |
Great thanks a lot, works like a charm |
sorry, I was to fast.. I forgot to reactivate the model binding in the service provider.. It's still not working.. |
Does no one of you guys use model binding? |
I don't know if the problem is caused by using the model binding. You need to edit your // resources/lang/de/routes.php
return [
'firma-abdeckung-id' => 'firma/abdeckung/{firma}',
// LaravelLocalization::transRoute('routes.firma-abdeckung-id')
];
// OR like this (I don't know if this package support it or not)
return [
'firma' => [
'abdeckung' => [
'show' => 'firma/abdeckung/{firma}',
// LaravelLocalization::transRoute('routes.firma.abdeckung.show')
],
],
];
// Same thing for other locales You can also check your model binding by doing this: $router->bind('firma', function($id) {
$record = \App\Firma::where('id', $id)->first();
dd($record); // This is only to see if everything is OK.
return $record;
}); |
Thanks for your response, I appreciate it. I'm pretty shure that it's caused by the model binding, because if I take it out, it all works great.. I tried your suggestion with using keys without '/', but it doesn't matter. And if I take the model binding out, it also works with keys with '/'. Thanks for your check code for the model binding. Yes it works all great. It's just that this function:
returns the false URL:
instead of the translated
The Routing itself, works with all translated routes, means:
|
I tried something.. If I call
Result: So this translation works, even with model binding.. this one not:
Result: So perhaps I can make a work-around with other functions from the package.. |
How about
|
Thanks, but it's not working, Result: I managed the links in the nav with this:
But I still couldn't find a usable solution for the Language switcher, because of different model binding parameters in different routes.. Then I would have to get dynamically the name of the model binding parameter, I don't like that.. I'm sorry i've read my posts again and realized that I didn't wrote clearly that the problem is just with the language switcher. Thank you all for any help |
I don't know exactly why this is not working but i'm curious about this issue. I've created my own localization package and i don't know if i've got the same issue. You can try it if you want : https://github.com/ARCANEDEV/Localization I can assist you to find out the issue and also to improve my package. NOTE : My package was based on |
Wow great, thank you very much for your support. I'll take a look at your package. |
You're welcome 👍 |
I fixed the issue in my localization package. To @mcamara, @BojanKogoj When we use route bindings, you need to be aware that you can have classes/models when you grab attributes from the request at this line. To fix it, you need to update the This is what i've done to fix it: ARCANEDEV/Localization#21 |
Thanks, your package works great. |
I have a issue with route translation with Model Binding, the route translation isn't working then:
Http/routes.php
en/routes.php
de/routes.php
I use Model Binding in app/Providers/RouteServiceProvider.php
Now if I am on the German site and push the link for English, it redirects me from:
to
instead of
It looks like its a Problem of the model binding, because if i take the model binding out, it works perfectly. Does anyone know something about this?
(I know there is also the possibility to translate the attributes, but I thought I will first get this to work without it)
The text was updated successfully, but these errors were encountered: