0
は、私の知る限りwhereNotExistsを理解し、それが渡されたクロージャ内のすべてのクエリを除外しなければならない作業ではありません。 しかし、予期しない結果が出ています。Laravel whereNotExistsが正しく
私は閉鎖の条件に適用される学生のすべてを返却されませんしようとしています。親が不在または欠席していない学生。私が得ているのは、空の学生配列[]です。
私は間違っていますか?
$students = DB::table('rounds')
->where('rounds.bus_id', '=', $bus_id)
->join('rounds_students', 'rounds_students.round_id', 'rounds.id')
->whereNotExists(function ($query) {
$query->select(DB::raw(1))
->from('student_history')
->where('student_history.student_id', '=', 'rounds_students.student_id')
->where('student_history.activity_type', '=', 'absent')
->orWhere('student_history.activity_type', '=', 'absent-by-parent');
})
->join('students', 'students.id', 'rounds_students.student_id')
->select('students.name')
->get();
return $students;
を試してみてください。ここであなたはまったくそれをしていません。 – apokryfos
@apokryfosは、私はすでにそれをしたが、質問にそれを言及するのを忘れ。その質問を更新しました。私はまだ空の$学生配列を持っています。 – WingsOfAltair