![](/img/trans.png)
[英]Base table or view not found: 1146 Table 'xyz.testimonials' doesn't exist (SQL: select * from `testimonials`)
[英]Base table or view not found: 1146 Table 'doctor1.education' doesn't exist (SQL: select * from `education` where `education`.`dr_id` in (1))
SQLSTATE [42S02]:未找到基表或視圖:1146 表 'doctor1.education' 不存在(SQL:select * from
education
whereeducation
.dr_id
in (1))
在這里我想在表教育中使用 hasMany 作為我的外鍵,這里醫生 id 是外鍵
醫生 Model 醫生表代碼:-
public function educations(){
return $this->hasMany('App\Models\Education','dr_id');
}
教育表的教育 model:-
public function doctor(){
return $this->belongsTo('App\Models\Doctor','dr_id');
}
Controller 此頁面的代碼:-
public function profilesetting(){
$userinfo = Doctor::with('educations')->where('id','=',session('drid'))->get();
dd($userinfo);
}
請告訴我如何解決這個錯誤?
在數據庫 model 中找不到表教育我認為在教育 model 中使用此行
protected $table = "educations";
謝謝你的建議,它會幫助我
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.