student, clubと student_clubを表すテーブルが3つあります。
下のような感じです。
+----------------------------+
| student |
+----------------------------+
| id, name |
+----------------------------+
+----------------------------+
| club |
+----------------------------+
| id, name |
+----------------------------+
+----------------------------+
| student_club |
+----------------------------+
| student_id, club_id |
+----------------------------+
Studentモデル
lang
1public function clubs() { 2 return $this->belongsToMany('Club'); 3} 4
Student::with('clubs')->get() のようなクエリは問題なくできます。
ですが、やりたいことは特定のクラブに当てはまる生徒だけを取得したいのです。
これをEloquentを使ってどうやればよいでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。