Reputation: 191
I'm using CakePHP with Firebird database with plugin cakephp-firebird-driver, and I need convert the related object keys to uppercase.
Controller:
$this->paginate = [
'contain' => ['Fazendas']
];
Result:
{
"LOTES": [
{
"ID": 12,
"LOTE": "\u003C 150 Kg",
"FAIXA_INICIAL": "0.000000",
"FAIXA_FINAL": "150.000000",
"FAZENDA_ID": 5,
"fazenda": {
"ID": 5,
"NOME": "FAZENDA 1",
"LOGRADOURO": null,
"INSCRICAO_ESTADUAL": null,
"CEP": null,
"TELEFONE": null,
"CNPJ": null,
"PROPRIETARIO_ID": null,
"CIDADE_ID": null
}
}
}
But the "fazenda" keeps in lowercase.
How I can do this?
Upvotes: 0
Views: 586
Reputation: 25698
Assuming that "fazenda" is an association and by convention in the entity it is converted to lower cased + underscored by default.
Change your property name for that assoc.
Example taken from the docs (read them!):
$this->belongsTo('Authors', [
'className' => 'Publishing.Authors',
'foreignKey' => 'authorid',
'propertyName' => 'person'
]);
Upvotes: 2
Reputation: 1913
May be your your relation is hasOne
or belongsTo
then you may add a property
'propertyName' => 'FAZENDA'
in relation array.
Upvotes: 1