glhd / gretel

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

Create fake parent breadcrumbs #11

Closed yakatz closed 1 year ago

yakatz commented 2 years ago

Is your feature request related to a problem? Please describe. I have routes that are 'nested', but the parent routes don't make any sense by themselves. For example, a user can get a text message that will take them to a special page, with the URL /sms/d/1234 (route name sms.dispatcher.call.show) or /sms/r/1234 (route name sms.responder.call.show). It wouldn't make any sense to have a route that was just /sms or /sms/d, but I would like to be able to prefix the breadcrumbs based on this route.

Describe the solution you'd like

Gretel::fakeBreadcrumb('sms', 'SMS');

Route::name('dispatcher.')->prefix('d')->group(function (){
    Route::get('{notification:smsKey}', [CallController::class, 'showSms'])->name('call.show')->breadcrumb('Dispatch Call', 'sms');
});

This would produce a breadcrumb trail like SMS > Dispatch Call

Describe alternatives you've considered The Gretel::breadcrumb() option requires that a route actually exist.

Additional context Similar to https://github.com/diglactic/laravel-breadcrumbs#breadcrumbs-with-no-url

inxilpro commented 1 year ago

Hm. I don't think this is something we're going to support right now. A potential solution would be to just create a simple redirect for that route and then wire it up that way…

Route::redirect('/sms', '/')
    ->name('sms.index')
    ->breadcrumb('SMS', 'home');

Route::get('/sms/{prefix}/{id}', CallController::class)
    ->name('sms.show')
    ->breadcrumb('Show SMS', 'sms.index');