2 つのテーブルから必要な情報をフィルタリングする必要がある 2 つのテーブルから結果を取得しようとしています。私がこれまでに持っているのはこれです:
// get list of students in this class;
$students = DB::table('students')
->join('userinfo', 'students.studentUserID', '=', 'userinfo.userinfoUserID')
->select('userinfo.userinfoInfo', 'userinfo.userinfoUserID')
->where('students.studentClassID', '=', $cid)
->get();
これはうまくいきますが、結果をさらにフィルタリングしたいと思います。userinfo 列を作成する方法は次のとおりです。
ID | userinfo.UserID | ユーザー情報.ユーザー情報タイプ | userinfo.userinfoInfo 2 | 3 | ファーストネーム | ジョニー 3 | 3 | 姓 | ベイカー 4 | 3 | 電話 | 5551234543
firstName 情報のみが必要です。だから、このようなもの:
->where('userinfo.userinfoType', '=', 'firstName')
Eloquent でこのようなクエリを実行するにはどうすればよいですか? ララベルを使用しています。