2
I have the following select in my controller:
$turmaAlunos = DB::select('
SELECT alunos.ST_ALUNO_ALU, alunos.ID_ALUNO_ALU
FROM alunos WHERE alunos.ID_ALUNO_ALU NOT IN (
SELECT turma_alunos.ID_ALUNO_ALU
FROM turma_alunos
INNER JOIN turmas ON turma_alunos.ID_TURMA_TUR = turmas.ID_TURMA_TUR
WHERE turma_alunos.ID_TURMA_TUR = ?
)
', [$id]);
It returns me what I need, however as stdClass and this is causing me the following error in the view when I try to traverse with foreach:
Undefined property: stdClass::$NM_MATRICULA_ALU
My view is like this:
@foreach($turmaAlunos as $turmaAluno)
<tr>
<td><input type="checkbox" name="alunos[]" value="{{ $turmaAluno->ID_ALUNO_ALU }}"></td>
<td>{{ $turmaAluno->NM_MATRICULA_ALU }}</td>
<td>{{ $turmaAluno->ST_ALUNO_ALU }}</td>
</tr>
@endforeach
How can I fix this?
Taking advantage, is there a better way to do this select without needing a subquery? And how do I do the way it is without being with DB::select brute?
I appreciate anyone who can help me!
Primary error this mine :/ Thank you very much!
– Matheus