Base table or view not found: 1146 Table 'doctor1.education' doesn't exist (SQL: select * from `education` where `education`.`dr_id` in (1))

Issue

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?

Solution

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

protected $table = "educations";

Answered By – HARSH JOLAPARA

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.