glhd / gretel

Laravel breadcrumbs right out of a fairy tale
MIT License
243 stars 16 forks source link

Group parameters are missing #7

Closed SergkeiM closed 2 years ago

SergkeiM commented 2 years ago

Describe the bug By wrapping resource into a Route Group with {parameter}, throws an error that parameter doesn't exists,

I've tried to pass the parameter as 3rd callback, but the same result.

What version does this affect?

To Reproduce

Route::resource('movies', 'MovieController')->except([
    'show'
])->breadcrumbs(function($breadcrumbs) {
    $breadcrumbs
        ->index('Movies')
        ->create('Create')
        ->edit('Edit', '.index');
});

Route::prefix('/movies/{movie}')->group(function () {

    Route::resource('actors', 'ActorController')->except([
        'index', 'show'
    ])->breadcrumbs(function($breadcrumbs) {
        $breadcrumbs
            ->create('Create', 'movies.index', fn($movie) => $movie)
            ->edit('Edit', 'movies.index', fn($movie) => $movie);
    });

});

Expected behavior Generate breadcrumbs

Additional context Throws an error:

Missing required parameter for [Route: actors.create] [URI: movies/{movie}/actors/create] [Missing parameter: movie].

inxilpro commented 2 years ago

Hm, I've dug into this a bit and can recreate the bug but it looks like it might be a bit tricky to sort out. We have to do some tricky stuff to have access to the route parameters at the right time, and it looks like some of that approach may need to be rethought to make nested groups work in this case.

inxilpro commented 2 years ago

Actually, can you try the current dev-main release? I think I found a solution…

inxilpro commented 2 years ago

This should be fixed in 1.6.0

SergkeiM commented 2 years ago

Hi @inxilpro apologies I didn't had time to check this, will do today and revert thank you.