-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[JSON:API] Usage Improvements #57960
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
base: json-api-resource
Are you sure you want to change the base?
[JSON:API] Usage Improvements #57960
Conversation
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
| ...(new Collection($this->filter($this->loadedRelationshipIdentifiers))) | ||
| ->map(function ($relation) { | ||
| return ! is_null($relation) ? $relation : ['data' => []]; | ||
| return ! is_null($relation) ? $relation : ['data' => null]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://jsonapi.org/format/#document-resource-object-linkage
data should be null for empty one-to-one relationship
| return ['id' => $uniqueKey[1], 'type' => $uniqueKey[0]]; | ||
| } | ||
| )]]]; | ||
| )]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix one-to-one relationship to display as object instead of array.
| public function resolveResourceData(Request $request) | ||
| { | ||
| return $this->toAttributes($request); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timacdonald I believe this should make it easier timacdonald/json-api forward compatible with a small change to TiMacDonald\JsonApi\JsonApiResource:
/**
* Resolve the resource data to an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function resolveResourceData(Request $request)
{
return $this->toArray($request);
}* wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Update src/Illuminate/Http/Resources/JsonApi/Concerns/ResolvesJsonApiElements.php --------- Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io>
Removed debug dump from JSON API resource test.
Uh oh!
There was an error while loading. Please reload this page.