Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for shallow nested resources #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dsazup
Copy link

@dsazup dsazup commented Aug 4, 2022

Hey! Just tried out this package and it seems great, but I run into a problem where shallow nested resources are not working correctly. I tried to fix this with limited amount of time and knowledge about this package, but seems like I got the tests to pass, so let me know if you think this is ok.

Basically if we have something like this (same as in the test) and we visit notes/1/edit, then it wouldn't display anything at all, because in the registry it's registered as users.notes.edit and not notes.edit, but the route when it is resolved has name of notes.edit. So this change basically makes sure it is registered with shallow name.

Route::resource('users', ResourceRoutesTestController::class)
    ->breadcrumbs([
        'index' => 'Users',
        'create' => 'New User',
        'edit' => 'Edit',
    ]);

  Route::resource('users.notes', NotesController::class)
    ->shallow()
    ->breadcrumbs(fn(ResourceBreadcrumbs $breadcrumbs) => $breadcrumbs
        ->show(fn(Note $note) => $note->note, 'users.index', fn(Note $note) => $note->user)
        ->edit('Edit', '.show', fn(Note $note) => $note->user)
    );

Let me know what you think 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant