Home > Back-end >  Base table or view not found: 1146 Table 'doctor1.education' doesn't exist (SQL: sele
Base table or view not found: 1146 Table 'doctor1.education' doesn't exist (SQL: sele

Time:06-08

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?

CodePudding user response:

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

protected $table = "educations";
  • Related