我有一个客户数据库。每个客户都可以拥有多个合同。每份合同都包含许多发票。
在Invoice视图中,我正在尝试显示client_name,但我只有contract_id,可以将Invoice链接到客户端。
我尝试了以下操作,但在调试数组时我只能检索发票和合约详细信息:
public function view($id = null) {
$this->Invoice->id = $id;
if (!$this->Invoice->exists()) {
throw new NotFoundException(__('Invalid invoice'));
}
$payment = $this->Invoice->find('first', array(
'conditions' => array(
'Invoice.id' => $id
),
'contain' => array(
'Contract' => array(
'Client'
)
)
));
$this->set('Invoice', $this->Invoice->read(null, $id));
}