Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@wukongrita

Description

@wukongrita
Issue body actions

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?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.