Customize getRouteKeyName() Laravel 5.6
I have a Location
model. The problem is that in my country exists locations of all levels with same name. So, I want to separate them by a custom field created from name
+ -
+ id
.
Is there a way of rewriting something like
public function getRouteKeyName()
{
return 'name';
}
In something like that :
public function getRouteKeyName()
{
return 'name' . '-' . 'id';
}
Meaning, I can access the route by /washington-24
, even this column don’t exists?
from Laravel Questions and Answers https://laravelquestions.com/php/customize-getroutekeyname-laravel-5-6/
via Lzo Media
No comments:
Post a Comment