Skip to content

Instantly share code, notes, and snippets.

@ahmadshobirin
Last active January 10, 2019 04:33
Show Gist options
  • Save ahmadshobirin/27b9acbc0df8af8e664ccdfb66e1e24c to your computer and use it in GitHub Desktop.
Save ahmadshobirin/27b9acbc0df8af8e664ccdfb66e1e24c to your computer and use it in GitHub Desktop.
public function classes($teacherId)
{
$teacherClass =
TeacherClass::join('m_class','m_class.id','m_teacher_class.class_id')
->select('m_teacher_class.class_id','m_class.name as name_class',
DB::raw("(select COUNT(*) from m_student where m_student.class_id = m_teacher_class.class_id ) as student")
)
->where('teacher_id',$teacherId)->get();
dd($teacherClass);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment