I have a scenario where I have to associate the same model with hasMany.
Has to Many relation for Children in PatientPaymentTransaction Model:
public $hasMany = [
'Children' => [
'className' => 'PatientPaymentTransaction',
'foreignKey' => false,
'dependent' => true,
// 'conditions' => ['Children.reference_id' => 'PatientPaymentTransaction.transaction_id' ],
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => 'SELECT *,children.reference_id as patient_payment_transaction_id FROM patient_payment_transactions children WHERE children.reference_id = {$__cakeID__$}',
'counterQuery' => ''
]
];
The response
The data is found but not appended in children.
What I am doing wrong?


Try to put it like this, inside the Model I am working my relationship
$hasManyis laid out like this: