To me it sounds like you need to bind your Eloquent model to the $id passed through the URL. You can do that by inserting it into the boot() method inside your App\Providers\RouteServiceProvider. It would look something like this:
public function boot(Router $router)
{
parent::boot($router);
$router->bind('mymodel', function($id)
{
return MyModel::findOrFail($id);
});
}
This can also go into your routes file with something like this:
Route::bind('mymodel', bind('mymodel', function($id)
{
return MyModel::findOrFail($id);
});
there are a couple other places as well but the nice thing is it's really your choice.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community