简体   繁体   中英

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]: Base table or view not found: 1146 Table 'doctor1.education' doesn't exist (SQL: select * from education where education . dr_id in (1))

here i want to use hasMany for my foreign key in table educations,here doctor id is foreign key

Doctor Model Code for doctors table:-

public function educations(){
        return $this->hasMany('App\Models\Education','dr_id');
    }

Education model for educations table:-

public function doctor(){
        return $this->belongsTo('App\Models\Doctor','dr_id');
    }

Controller Code for this page:-

public function profilesetting(){
        $userinfo = Doctor::with('educations')->where('id','=',session('drid'))->get();
        dd($userinfo);
    }

please tell me that how i solve this error?

in database model cant find table educations i think use this line in Education model

protected $table = "educations";

Thank you for the advice,it will help me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM