cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
780 stars 109 forks source link

How to include relationship data ? #527

Closed lironesamoun closed 4 years ago

lironesamoun commented 4 years ago

I'm fetching users and my response so far is the following :

    type: "users",
    id: "1",
    attributes: {
    name: "myname",
    email: "name@domain",
    },
    relationships: {
       roles: {
          data: [
            {
              type: "roles",
              id: "9"
            }
          ],
          links: {
            self: "http://127.0.0.1:8000/api/v1/users/1/relationships/roles",
            related: "http://127.0.0.1:8000/api/v1/users/1/roles"
            }
          }
          },
          links: {
            self: "http://127.0.0.1:8000/api/v1/users/1"
          }
      },

How is it possible to include in my relationship data, the attribute ? Like

  roles: {
          data: [
            {
              type: "roles",
              id: "9"
              name : "Admin"
            }
          ],

I'm not sure, I saw that info on the doc if it's possible to do that or not.

Thank in advance

ben221199 commented 4 years ago

Duplicate of #523

lindyhopchris commented 4 years ago

Closing, see https://github.com/cloudcreativity/laravel-json-api/issues/523#issuecomment-658840713