Arrange json with Eloquent [closed]

1

My question is this: I want to organize my json so that I can see the Animal and Farm table, but organized, for example:

{
"animais": {
    "id": 1,
    "nome": "Mimosa",
    "data_nascimento": "2017-04-11 00:00:00",
    "codigo_brinco": "Não informado",
    "codigo_raca": "Não informado",
    "status": 1,
    "data_alteracao": "2018-02-13 00:00:00",
    "data_cadastro": "2018-02-13 00:00:00",
    "usuario_cadastro": 1,
    "usuario_alteracao": null,
    "fazendas_id": 1,
    "lotes_id": 1,
    "fazenda": {
        "id": 1,
        "nome": "Fazenda Nossa Senhora aparecida",
        "data_alteracao": "2018-02-13 00:00:00",
        "data_cadastro": "2018-02-13 00:00:00",
        "usuario_cadastro": 1,
        "usuario_alteracao": "1",
        "status": 1
    }
}

Note that it has an attribute of json called "farm" which is another table, but I can not do this without being find($id) of Eloquent would have another way of doing such thing?     

asked by anonymous 13.02.2018 / 15:00

0 answers