model/entity/Order.php에 가상 파일을 구현했습니다.cakephp에서 모델 엔터티 대신 컨트롤러의 가상 필드에 액세스하는 방법 3.2
하지만 한 페이지 만 액세스하고 싶습니다. 모든 기능을 호출하지 않아도됩니다. 컨트롤러에서 어떻게 가상 필드에 액세스하여 필요한 부분에만 적용 할 수 있습니까?
cakephp 2x 버전에서는 컨트롤러 용으로 만들었지 만 이번에는 3 배속으로 만들 수 없습니다. 제가
아래상관 제안 이해할 것이다 일부 코드
붙어있다. 감사합니다. 컨트롤러
모델/엔티티/Order.php
protected $_virtual = ['amount'];
protected function _getAmount() {
$data = [];
$data['due'] = $this->_properties['collection']['due_amount'];
$data['paid'] = $this->_properties['collection']['total_sale_amount'] - $this->_properties['collection']['due_amount'];
return $data;
}
코드는
$Lists = $this->Orders->find('all')->where($condition)->contain(['Collections','Customers'=> ['queryBuilder' => function ($q) {
return $q->select(['id','center_name']);
}],])->order(['Orders.due_date ASC']);
좋습니다. 시도해 보겠습니다. 감사합니다. – sradha
하지만 오류 : 정의되지 않은 메소드 App \ Model \ Entity \ Order :: amount()와 같은 오류가 발생합니다. – sradha
foreach 루프에있는 객체의 유형을 디버그 ($ 엔티티) 할 수 있습니까? –