-
Notifications
You must be signed in to change notification settings - Fork 35
Support to-many relations in included resources. #84
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
Conversation
Any updates on this one? It looks like this is also the cause for nilportugues/laravel5-jsonapi#39. |
$existingIndex = self::findIncludedIndex($data[JsonApiTransformer::INCLUDED_KEY], $arrayData[JsonApiTransformer::ID_KEY], $arrayData[JsonApiTransformer::TYPE_KEY]); | ||
} | ||
if ($existingIndex !== false) { | ||
$data[JsonApiTransformer::INCLUDED_KEY][$existingIndex] = \array_filter(\array_merge($data[JsonApiTransformer::INCLUDED_KEY][$existingIndex], |
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.
Opening parenthesis of a multi-line function call must be the last content on the line
} | ||
if ($existingIndex !== false) { | ||
$data[JsonApiTransformer::INCLUDED_KEY][$existingIndex] = \array_filter(\array_merge($data[JsonApiTransformer::INCLUDED_KEY][$existingIndex], | ||
\array_filter($arrayData, self::filterEmptyArray())), self::filterEmptyArray()); |
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.
- Multi-line function call not indented correctly; expected 20 spaces but found 24
- Closing parenthesis of a multi-line function call must be on a line by itself
if (!empty($data[JsonApiTransformer::INCLUDED_KEY])) { | ||
$data[JsonApiTransformer::INCLUDED_KEY] = \array_values( | ||
\array_unique($data[JsonApiTransformer::INCLUDED_KEY], SORT_REGULAR) | ||
); | ||
} | ||
} | ||
|
||
protected static function filterEmptyArray() | ||
{ | ||
return function($value) { |
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.
Expected 1 space after FUNCTION keyword; 0 found
I noticed an issue while using your awesome library.
It's currently not possible to include "to-many" relations that are defined in included resources. For example if you have Post and Comment objects like in your unit tests and you want to include an array of "likes" in the Comment object, these aren't included in the result.
Because this is my first pull request, I welcome all kinds of critique. ;)