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

Conversation

@LasseRafn
Copy link
Contributor

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');
LasseRafn added 2 commits Mar 9, 2020
@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
7 checks passed
7 checks passed
P7.2 - Sprefer-lowest
Details
P7.2 - Sprefer-stable
Details
P7.3 - Sprefer-lowest
Details
P7.3 - Sprefer-stable
Details
P7.4 - Sprefer-lowest
Details
P7.4 - Sprefer-stable
Details
continuous-integration/styleci/pr The analysis has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.