0
IDの代わりに値を表示するにはどうすればよいですか?CakePHP 3形式で関連データを表示
表文書が含まれています ID、タイトル、本文、PERSON_ID、(それが重要な場合)私はこのようなではなくDocumentsControllerで取得
をreview_date:.ctpで
$test = $this->Documents->find('all',['conditions' => ['review_date'=>date('Y-m-d', strtotime('2022-01-01')) ] ]);
をそれが示してこのような:
<tbody>
<?php foreach ($test as $document): ?>
<tr>
<td><?= $document->id; ?></td>
<td><?= $document->person_id; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
そして、私が代わりにPERSON_IDの人の名前を表示したいです。 ...
public function add()
{
$this->loadModel('Documents');
$this->loadModel('Persons');
$this->loadModel('SelfReports');
$this->loadModel('PlannedQuestions');
$agenda = $this->Agendas->newEntity();
if ($this->request->is('post')) {
$agenda = $this->Agendas->patchEntity($agenda, $this->request->getData());
if ($this->Agendas->save($agenda)) {
$this->Flash->success(__('The agenda has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The agenda could not be saved. Please, try again.'));
}
$per = $this->Persons->find('all');
$tes = $this->Documents->find('all',[
'conditions' => ['review_date'=>date('Y-m-d', strtotime('2022-01-01'))],
'fields' => ['Documents.id','RefArticles.article_number','Persons.name']]);
$selfreports = $this->SelfReports->find('all',['conditions' => ['next_visit_date'=> date('Y-m-d', strtotime('thursday this week'))]]);
$plannedquestions = $this->PlannedQuestions->find('list');
$this->set(compact('agenda', 'tes'));
$this->set('_serialize', ['agenda']);
}