I have eager loaded the data but when I am using $object->attribute it again fetch the data from database.
My query is :
$user = User::with([
'Comment' => function($query){
$query->where('active', 1);
$query->with('CommentReply.User');
$query->orderBy('updated_at', 'desc');
}
]);
But when I use $user->comment then it again load all the comments, which results to N+1 problem. Any reason why this is happening? Thanks in advance.