class Test extends Model implements \Mcamara\LaravelLocalization\Interfaces\LocalizedUrlRoutable
{
public function getLocalizedRouteKey($locale)
{
dd("stop!");
return $this->getTranslation('slug',$locale);
}
}
Continuing with the documentation I tried to implement the resolveRouteBinding
class Test extends Model implements \Mcamara\LaravelLocalization\Interfaces\LocalizedUrlRoutable
{
public function getLocalizedRouteKey($locale)
{
dd("stop!");
return $this->getTranslation('slug',$locale);
}
public function resolveRouteBinding($slug, $field = null)
{
dd("I'm here");
return static::findByLocalizedSlug($slug)->first() ?? abort(404);
}
}
But is never fired that olso.
The resoult is the model slug,using LaravelLocalization::getLocalizedURL('en') is equal for any locale
Describe the bug In my case I have the translated slug in the database, using a package to translate the models. After some search I deep into the solution given here https://github.com/mcamara/laravel-localization#translatable-route-parameters
My model is this:
But getLocalizedRouteKey in never fired.
The fron end is this:
<a rel="alternate" href="{{ LaravelLocalization::getLocalizedURL('en') }}">EN</a> <a rel="alternate" href="{{ LaravelLocalization::getLocalizedURL('fr') }}">FR</a>
Continuing with the documentation I tried to implement the
resolveRouteBinding
But is never fired that olso.
The resoult is the model slug,using LaravelLocalization::getLocalizedURL('en') is equal for any locale
route.php
ENroute.php
FRExample for slug beutiful-house in EN
LaravelLocalization::getLocalizedURL('en') return http://site.y/maisons/beutiful-house LaravelLocalization::getLocalizedURL('fr') return http://site.y/maisons/beutiful-house
I wnt to override the beutiful-house in french!
Laravel v10.33.0 (PHP v8.2.13) latest mcamara