在這里,我需要使用預(yù)訂表的數(shù)據(jù)根據(jù) Students_id 獲取連接的教師和連接的科目的數(shù)量。如果 Student_id = 1,則提供教師計數(shù) = 2,因為連接的 Teacher_id 僅是 1 和 2。然后,student_id = 1 提供主題計數(shù) = 3,因為連接的 subject_id 僅是 3,1 和 2。我如何在 laravel 中實現(xiàn)這個功能?
1 回答

慕哥6287543
TA貢獻(xiàn)1831條經(jīng)驗 獲得超10個贊
我想你可以做這樣的事情:
DB::table('reservations') ->where('student_id', $student_id) ->distinct('teacher_id') ->count('teacher_id');
這會獲取id: 的學(xué)生的預(yù)訂$student_id
,然后計算所有不同的教師 id。
- 1 回答
- 0 關(guān)注
- 122 瀏覽
添加回答
舉報
0/150
提交
取消