Good, I have a view where I receive a "subject id", "student id" and I want to show the qualifications that ESE student has in ESA ASIGNATURA.
I have the following function
public function verCalificacion($id, $idasi)
{
$alumno = Alumno::find($id);
$asignatura = Asignatura::find($idasi);
$mis_notas = $alumno->calificaciones; // ????
return view('datos-profesor.vercalificacion')->with('alumno',$alumno)->with('mis_notas',$mis_notas)->with('asignatura',$asignatura);
}
where I receive the corresponding ids, but I do not know how to use the relationship to return the grades of a student in a subject, in the table Qualifications of the database I have the corresponding foreign ids and these are the relations
Rating
public function alumno()
{
return $this->belongsTo(Alumno::class, 'id_alumno', 'id');
}
public function asignatura()
{
return $this->belongsTo(Asignatura::class, 'id_asignatura', 'id');
}
Student
public function calificaciones()
{
return $this->hasMany('App\Calificacion','id_alumno');
}
Subject
public function calificaciones()
{
return $this->hasMany('App\Calificacion','id_asignatura');
}
Try a couple of wheres but it does not work for me, who can help me please. Thanks in advance.