0
송장을 보낼 때 발신자와 수신자 간의 관계가 활성화되어야하는 사이트를 만들려고합니다. 이 작업은 별도의 테이블에서 수행되며 다른 테이블에서 부울 값 1이 필요합니다. cakephp, 유효성 검사가 별도의 테이블에 있음
송장
는 다음과 같은 구조로 테이블invoices
에 저장됩니다 :
id
sender
receiver
amount
date due
relationship
테이블 구조는 다음과 같습니다
id
partyone
partytwo
active
partyone
및 partytwo
참조 사용자 테이블. 관계 테이블 partyone 및 partytwo 포함되어 있고 경우
id
username
password
, 부울 하나 같다 :
users
표는 다음과 같은 구조를 가지고 있습니다.
이것은 청구서 테이블에 새로운 인보이스를 추가하는 기능입니다. 사용자가 해당 사용자와 활발한 관계에 있기 전에는 데이터베이스에 추가 할 수 없습니다.
public function addinvoice(){
if($this->request->is('post')) {
$this->Invoice->create();
if (0 === $this->relationship->find('count',array('conditions'=>array('activate'=>1,'relationship'=> $relationship)))) {
$this->Session->setFlash('Sorry, you do not have an active relationship.');
$this->redirect($this->referer());
}
if ($this->Invoice->save($this->request->data)){
$this->Session->setFlash('The invoice has been saved');
}
} else {
$this->Session->setFlash('The invoice could not be saved. Please, try again.');
}
}
이 답변이 도움이 발견하는 경우, 당신은 정답으로 선택하시기 바랍니다 수 있습니까? –