App\Models\Test cannot use Mcamara\LaravelLocalization\Interfaces\LocalizedUrlRoutable - it is not a trait
My model is this:
class Test extends Model implements \Mcamara\LaravelLocalization\Interfaces\LocalizedUrlRoutable
{
public function getLocalizedRouteKey($locale)
{
dd("stop!");
return $this->getTranslation('slug',$locale);
}
}
But it seem getLocalizedRouteKey in never fired.
Continuing with the documentation I tried to implement the resolveRouteBinding function, but I have this error:
class Test extends Model implements \Mcamara\LaravelLocalization\Interfaces\LocalizedUrlRoutable
{
public function getLocalizedRouteKey($locale)
{
dd("stop!");
return $this->getTranslation('slug',$locale);
}
public function resolveRouteBinding($slug)
{
return static::findByLocalizedSlug($slug)->first() ?? abort(404);
}
}
Method 'App\Models\Test::resolveRouteBinding()' is not compatible with method 'Illuminate\Database\Eloquent\Model::resolveRouteBinding()'.intelephense(P1038)
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 but using it get me fatal error:
App\Models\Test cannot use Mcamara\LaravelLocalization\Interfaces\LocalizedUrlRoutable - it is not a trait
My model is this:
But it seem getLocalizedRouteKey in never fired.
Continuing with the documentation I tried to implement the
resolveRouteBinding
function, but I have this error:Method 'App\Models\Test::resolveRouteBinding()' is not compatible with method 'Illuminate\Database\Eloquent\Model::resolveRouteBinding()'.intelephense(P1038)