0
![Stack Overflow](http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png)
Your problem is here
$query->where('user_id',Auth::user()->id)
->orWhereIn('user_id',Auth::user()->friends()->lists('id')
);
Your query is selecting data for Auth::user() instead of $user
$posts=Post::where(function($query) use ($user) {
$query->where('user_id',$user->...