多對多關聯報錯:類的屬性不存在:app\common\model\Course->id

瀏覽:100 發布日期: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}
最佳答案
評論( 相關
后面還有條評論,點擊查看>>
滚雪球理财骗局揭秘