Returning tables with hasMany - CakePHP

0

In a belongsToMany relationship, when I transform the result into json it returns the _joinData field.

Would there be any way to not bring it into the query or display it in json using any 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

    
asked by anonymous 22.03.2016 / 22:50

1 answer

2

You can hide the display of this field by adding it in the _hidden your entity, like this:

protected $_hidden = ['_joinData'];
    
04.04.2016 / 16:04