1$users = User::whereHas('posts', function($q){
2 $q->where('created_at', '>=', '2015-01-01 00:00:00');
3})->get();
4// only users that have posts from 2015 on forward are returned
5
1User::select()->whereHas('student', $function($q) {
2 $q->where('name', $value)
3 ->orWhere('age', $value2);
4 });