-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[JSON:API] Supports JsonApiResource::toRelationships()
#57646
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
Merged
Merged
Changes from 28 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
c69a2e5
[JSON:API] Supports `JsonApiResource::toRelationships()`
crynobone cd01fa7
Apply fixes from StyleCI
StyleCIBot ec25825
wip
crynobone 9a0a8fe
Apply fixes from StyleCI
StyleCIBot 3ee71cc
wip
crynobone 096ce53
Merge remote-tracking branch 'upstream/json-api-resource' into json-a…
crynobone 5a3f43f
wip
crynobone 6de34f6
Update JsonApiResource.php
taylorotwell 04e0d2e
only include relationship if defined
taylorotwell a89fd69
formatting
taylorotwell b0eaf03
tweak how relations work
taylorotwell 04bfaad
work on relationships
taylorotwell 2479bae
fixes implementation
crynobone f2ffda0
Add `JsonApiRequest`
crynobone 04fc800
Apply fixes from StyleCI
StyleCIBot 2e56f97
wip
crynobone caf5c9c
Merge remote-tracking branch 'upstream/json-api-resource-relations' i…
crynobone 334b9c2
wip
crynobone 5930c7d
wip
crynobone 0828655
wip
crynobone 4a09643
formatting
taylorotwell 2b7861e
wip
crynobone 51f5f9f
Apply fixes from StyleCI
StyleCIBot 227ef2a
wip
crynobone a7ec8d0
Apply fixes from StyleCI
StyleCIBot a949f45
wip
crynobone 1fcd9a7
Apply fixes from StyleCI
StyleCIBot 3cde253
Add `make:resource` with `--json-api` option
crynobone a9d041d
Apply suggestions from code review
crynobone f59070b
ensure request is always `JsonApiRequest`
crynobone d320641
wip
crynobone 4ae7eb7
wip
crynobone 2e6d941
Apply fixes from StyleCI
StyleCIBot 64cacc9
wip
crynobone 5748a9f
wip
crynobone acbde38
Apply fixes from StyleCI
StyleCIBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Illuminate/Foundation/Console/stubs/resource-json-api.stub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| namespace {{ namespace }}; | ||
|
|
||
| use Illuminate\Http\Request; | ||
| use Illuminate\Http\Resources\JsonApi\JsonApiResource; | ||
|
|
||
| class {{ class }} extends JsonApiResource | ||
| { | ||
| /** | ||
| * Transform the resource into an array. | ||
| * | ||
| * @return array<string, mixed> | ||
| */ | ||
| public function toAttributes(Request $request): array | ||
| { | ||
| return parent::toArray($request); | ||
crynobone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Illuminate/Http/Resources/JsonApi/Concerns/ResolvesJsonApiRequest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
|
|
||
| namespace Illuminate\Http\Resources\JsonApi\Concerns; | ||
|
|
||
| use Illuminate\Http\Request; | ||
| use Illuminate\Http\Resources\JsonApi\JsonApiRequest; | ||
|
|
||
| trait ResolvesJsonApiRequest | ||
| { | ||
| /** | ||
| * Resolve a JSON API request instance from the given HTTP request. | ||
| * | ||
| * @return \Illuminate\Http\Resources\JsonApi\JsonApiRequest | ||
| */ | ||
| protected function resolveJsonApiRequestFrom(Request $request) | ||
| { | ||
| return $request instanceof JsonApiRequest | ||
| ? $request | ||
| : JsonApiRequest::createFrom($request); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.