Laravel Docs says:
Sometimes you may wish to use your own resolver for route parameters. Simply use the Route::bind method:
Route::bind('user', function($value, $route) { return User::where('name', $value)->first(); });
using the above you could setup a route service provider. Something like this
class RoutesServiceProvider
{
//Inject reposiotry into constructor
public function $register($app)
{
$app['router']->bind('model', function($id, $route)) {
return $this->modelRepository->findById($id);
}
}
}
Thank you very much! I can't implement it right now but wanted to thank you for taking the time to answer so clearly. I'll update my replay as soon as I have chance to add the code.
Thanks damienadermann, really appreciate the help!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community