多对多关联报错:类的属性不存在:app\common\model\Course->id

浏览:1209 发布日期:2020/02/21 分类:ThinkPHP5专区 关键字: thinkphp5多对多关联 类的属性不存在



M层
class Course extends Model
{
public function Klasses(){
return $this->belongsToMany('Klass', config('database.prefix') . 'klass_course');}
}

C层
------------------------------------------------------------
public function add()
{
$this->assign('Course', new SmallCourse);
return $this->fetch();
}

V层
--------------------------------------------------------------------------------
{volist name="Course->Klasses()->select()" id="klass"}
<input type="checkbox" name="klass_id[]" id="klass_id_{$klass->id}" value="{$klass->id}" />
<label for="klass_id_{$klass->id}">{$klass->name}</label>
{/volist}
最佳答案
评论( 相关
后面还有条评论,点击查看>>