0
I would like to search all people of a certain class based on the class code using Laravel:
And right after paginate, to make a list.
Pupil
public function turmas()
{
return $this->belongsToMany(Turma::class,'turma_classe', 'turma_id','aluno_id');
}
Gang
public function alunos()
{
return $this->belongsToMany(Aluno::class,'turma_classe', 'aluno_id','turma_id');
}
Seeking
$aluno = Aluno::find(1);
$turmas = $aluno->turmas;
foreach($turmas as $turma)
{
var_dump(Aluno::with(Turma::class)->where('codigo', $turma->codigo));
}
Are you using any code? and/or are you using
Model
? if yes you can provide in the question!– novic
The correct question is: Search all
Alunos
of a certainTurma
? that’s it?– novic
I’ll update the question
– ALE_ROM
Yes, using the code of
Turma
– ALE_ROM