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

[7.x] Add apiResource in RouteRegistrar #31857

Merged
merged 2 commits into from
Mar 9, 2020
Merged

[7.x] Add apiResource in RouteRegistrar #31857

merged 2 commits into from
Mar 9, 2020

Conversation

LasseRafn
Copy link
Contributor

@LasseRafn LasseRafn commented Mar 9, 2020

Since Laravel 7.X has a new (optimized) routing implemented, route names are more important, and caching routes will break if naming collisions happen.

Normally you can use Route::name('posts')->resource(..... to change the name of a group (useful for nested routes like: /posts/{post}/comments)

HOWEVER, this is not possible with apiResource.

I propose this change to allow that. Its just a convenience to replace:

Route::name('posts')->resource('posts/{post}/comments', 'PostCommentsController')->only(['index', 'show', 'store', 'update', 'destroy']);

With:

Route::name('posts')->apiResource('posts/{post}/comments', 'PostCommentsController');

@GrahamCampbell GrahamCampbell changed the title Add apiResource in RouteRegistrar [7.x] Add apiResource in RouteRegistrar Mar 9, 2020
@taylorotwell taylorotwell merged commit a2ca152 into laravel:7.x Mar 9, 2020
@LasseRafn LasseRafn deleted the patch-1 branch January 28, 2021 11:24
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.

2 participants