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