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

How do I use getResourceKey() on Relationship? #177

Open
wukongrita opened this issue Mar 9, 2021 · 0 comments
Open

How do I use getResourceKey() on Relationship? #177

wukongrita opened this issue Mar 9, 2021 · 0 comments

Comments

@wukongrita
Copy link

Hi @flugg ,

I have setup my models with getResourcKey() for both models:

NelitiVolume.php

. . .
    public function getResourceKey(): string {
        return 'neliti-volumes';
    }
. . .

NelitiPublication.php

. . .
    public function getResourceKey(): string {
        return 'neliti-publications';
    }
. . .

When I try to get the result from the url using /neliti-volumes?include=neliti-publication, I get the type is using camel-case; not using the kebab-case that I already defined in the models:

{
  "data": [
    {
      "type": "neliti-volumes",
      "id": "088f4670-8993-4ffc-86e4-58036442cebe",
      "attributes": {
        "volume": "BB",
        "number": "3",
      },
      "relationships": {
        "neliti-publication": { // this one is from the url that mapped with the transformers
          "data": {
            "type": "nelitiPublication", // this one should be neliti-publications that get from getResourceKey()
            "id": "39676c75-6e03-11ea-9660-ed7fb61131c5"
          }
        }
      }
    },
    . . .
  ]
}

Btw, I am using JSON API Serializer from PHP League...

Did I miss something?

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

No branches or pull requests

1 participant