Skip to content

Conversation

@niels-numbers
Copy link
Contributor

I think by default one may would like to return the relations $post->author and not a single column $post->createdBy. Also createdBy is not a standard attribute, so I guess it was a typo?

I think by default one may would like to return the relations `$post->author` and not a single column `$post->createdBy`. Also `createdBy` is not a standard attribute, so I guess it was a typo?
@lindyhopchris
Copy link
Member

This is intentional as it is showing that you don't need to call the JSON API relationship the same name as the model relationship. So I'm not sure about changing it?

@niels-numbers
Copy link
Contributor Author

niels-numbers commented Nov 28, 2019

I see, but there are already existing examples in schema.md that show how to use custom attributes:

return [
          'comments' => [
              self::META => function () use ($post) {
                  return [
                      'total' => $post->comments_count,
                  ];
              },
          ],
      ];

@lindyhopchris
Copy link
Member

Ah that's showing something different - that's showing meta, rather than returning the actual related resource.

@nelson6e65
Copy link

This was confusing for me when reading documentation. I was looking for a convention about createdBy as standard relationship 😅

@lindyhopchris lindyhopchris merged commit 8a2cbfb into cloudcreativity:master Apr 12, 2020
@lindyhopchris
Copy link
Member

Ok, thanks for the feedback all and I've merged this now.

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.

3 participants