breadcrumbs icon indicating copy to clipboard operation
breadcrumbs copied to clipboard

Does this package support route group binding?

Open matheusmartinsdev opened this issue 9 months ago • 3 comments

Hi! First at all, thank you for this great package!

I have a question: I've tried to get a route group param binding in breadcrumb, but I can't.

This code below results an error:

Illuminate\Routing\RouteFileRegistrar::{closure}(): Argument #2 ($benefit) must be of type App\Models\DRH\Benefit, string given.

Route::group([
    'prefix' => 'beneficios',
    'as' => 'benefits.',
    'middleware' => ['auth'],
], function () {
    Route::group([
        'prefix' => '{benefit:slug}/reembolsos',
        'as' => 'reimbursements.'
    ], function () {
        Route::get('/', ListAll::class)
            ->name('index')
            ->breadcrumbs(
                fn (\Tabuna\Breadcrumbs\Trail $trail) => $trail->push('Benefícios', route('benefits.index'))
            );

///////////// ERROR HAPPENS IN THE ROUTE BELLOW: \\\\\\\\\\\\\\\\\\\\\\
        Route::get('solicitar', Create::class)
            ->name('create')
            ->breadcrumbs(
                fn (\Tabuna\Breadcrumbs\Trail $trail, \App\Models\DRH\Benefit $benefit) => $trail->parent('benefits.reimbursements.index')
                    ->push("Solicitar reembolso para {$benefit->name}")
            );
    });

// ... other routes
});

What am I doing wrong?

Thanks!

matheusmartinsdev avatar Mar 17 '25 11:03 matheusmartinsdev

Hey! 👋 I'll try to check the reproduction of the issue over the weekend. However, the model should be passed into the closure if it's available in the route arguments.

A quick guess: maybe it's still not working if you replace the model {benefit:slug} with {benefit}?

tabuna avatar Mar 18 '25 22:03 tabuna

Hey! 👋 I'll try to check the reproduction of the issue over the weekend. However, the model should be passed into the closure if it's available in the route arguments.

A quick guess: maybe it's still not working if you replace the model {benefit:slug} with {benefit}?

Hey, thanks for the answer. Yes, I've tried to replace {benefit:slug} with {benefit} and no success

matheusmartinsdev avatar Mar 22 '25 13:03 matheusmartinsdev

Hey! I tried specifying the group, prefix, and other parameters, but I couldn’t reproduce the issue. Maybe I’m missing something. Could you provide a minimal reproducible example? That would really help in figuring this out. 😊

tabuna avatar Mar 24 '25 08:03 tabuna