grepper add code answer
to connect relationships and display foreign has links. need to identify
*ngIf this.bankAccounts.id == this.company.id similar to Ionic
public function index($id = null)
{
$this->paginate = [
'contain' => ['Organizations','Banks', 'Companies'],
];
$bankAccounts = $this->BankAccounts->find();
if($id){
$bankAccounts->where(['organization_id' => $id]);
$organization = $this->BankAccounts->Organizations->findById($id)->first();
$this->set('organization', $organization);
}
if ($id){
$bankAccounts->where(['company_id' => $id]);
$company = $this->BankAccounts->Companies->findById($id)->first();
$this->set('company', $company);
}
$bankAccounts = $this->paginate($this->BankAccounts);
$this->set(compact('bankAccounts'));
}
public function edit($id = null)
{
$bankAccount = $this->BankAccounts->get($id, [
'contain' => [],
]);
$bankAccount = $this->BankAccounts->find();
if($id){
$bankAccount->where(['organization_id' => $id]);
$organization = $this->BankAccounts->Organizations->findById($id)->first();
$this->set('organization', $organization);
}
if ($id){
$bankAccount->where(['company_id' => $id]);
$company = $this->BankAccounts->Companies->findById($id)->first();
$this->set('company', $company);
}
if ($this->request->is(['patch', 'post', 'put'])) {
$bankAccount = $this->BankAccounts->patchEntity($bankAccount, $this->request->getData());
if ($this->BankAccounts->save($bankAccount)) {
$this->Flash->success(__('The bank account has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The bank account could not be saved. Please, try again.'));
}
$organizations = $this->BankAccounts->Organizations->find('list', ['limit' => 200]);
$companies = $this->BankAccounts->Companies->find('list', ['limit' => 200]);
$banks = $this->BankAccounts->Banks->find('list', ['limit' => 200]);
$this->set(compact('bankAccount', 'organizations', 'companies', 'banks'));
}