I am really not getting why this eager loading is not working when I try to return specific columns. This code works perfectly
$user=User::where('userName', $userName)
->with('points')
->with('examstaken')
->with('question')
/*->with(array('points'=>function($query){
$query->select('id','points');
}))*/
->get();
This code doesn't wort
$user=User::where('userName', $userName)
/*->with('points')*/
->with('examstaken')
->with('question')
->with(array('points'=>function($query){
$query->select('id','points');
}))
->get();
Doesn't work mean, 'points' doesn't return any value while the first one return the values correctly..
Any idea what's wrong with it?
Here is the relation in my user model
public function points()
{
return $this->hasMany('App\Points','user_id');
}
Thanks..