Return tables with hasMany - Cakephp

Asked

Viewed 32 times

0

In a relationship belongsToMany, when I turn the result into json ends up returning the field _joinData.

Would there be some way not to bring him to the appointment or not to display on json using some Cake option?

JSON example:

{
  "id": 1,
  "name": "Produto Teste",
  "slug": "produto-teste",
  "cover": null,
  "categories": [
    {
      "name": "Bebida",
      "_joinData": {
        "category_id": 1,
        "id": 5,
        "product_id": 1
      }
    },
    {
      "name": "Roupa",
      "_joinData": {
        "category_id": 2,
        "id": 6,
        "product_id": 1
      }
    }
  ]
},

Edit: I’m using version 3.2

1 answer

2


You can hide the display of this field by adding it to the property _hidden of its entity, thus:

protected $_hidden = ['_joinData'];
  • It worked perfectly, thank you very much :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.