vendredi 22 février 2019

Error : Method Illuminate\Database\Eloquent\Collection::StudentInfo does not exist. (Laravel 5.6)

I am new to make join tables with Eloquent. I want to join 3 tables. But it shows me error. What's my mistake, if anyone notice it will be helpful for me. Here is tables.... In 1st table Applications(id,u_id,program_name) 2nd table StudentInfos(id,u_id,.....) 3rd table users(id,.....)

in Application model

public function StudentInfo()
{
    return $this->hasOne('App\StudentInfo', 'u_id', 'u_id');

}

in StudentInfo model

public function User()
{
    return $this->hasOne('App\user', 'u_id', 'id');

}

From controller

 public function view_application($id)
  {
    $vu_data = Application::where('id', $id)->get();
    $vu_data2 = $vu_data->StudentInfo()->get();
    return $vu_data2;

  }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire