JohnRivs
4 years ago
115
9
General

[L5.1] Route-Model binding for a nested resource?

Posted 4 years ago by JohnRivs

I got a few resources going on like this:

Route::resource('foo', 'FooController');
Route::resource('bar', 'BarController');
Route::resource('foo.bar', 'FooBarController');

I applied Route-Model binding correctly for Route::get('foo/{foo}', 'FooController@show');:

Route::bind('foo', function($value) {
    return \App\Foo::where('something', $value)->first(['column_a', 'column_B']);
});

I'm wondering, how am I suppose to do it for foo and bar in foo/{foo}/bar/{bar}?

Please sign in or create an account to participate in this conversation.