0
我試圖通過查看用戶是否可以註冊課程來運行。我有2個問題:CakePHP:允許用戶註冊課程
- 我正在以正確的方式進行嗎?
- 我的學生:: isSignedUpForCourse()函數沒有返回正確的課程(它實際上返回2門課程)。我怎樣才能將它在課程模型中被使用的課程(課程:: CanSignupForCourse)發送給它?
謝謝!
// Course Model
public function isComplete() {
$course = $this->read(null);
if($course['Course']['completed'] != 0) {
return true;
}
return false;
}
public function canSignupForCourse($studentId) {
$this->Student->id = $studentId;
if (!$this->Student->exists()) {
throw new NotFoundException(__('Invalid student'));
}
$this->Student->isSignedUpForCourse();
//this will ultimately be:
//if(! $this->Student->isSignedUpForCourse && $this->isApproved()) {
// return
}
}
// Course Controller:
public function signup($id = null) {
$this->Course->id = $id;
if (!$this->Course->exists()) {
throw new NotFoundException(__('Invalid course'));
}
if($this->Course->canSignupForCourse($this->Auth->user('id'))) {
// can signup
}
}
// Student Model
public function isSignedUpForCourse() {
print_r($this->read());
}
這是課程模型。 – execv 2012-02-23 01:18:38
看到我上面的更新。 – 2012-02-23 03:31:42