First, you can retreive the authenticated user with "Auth::user()" instead of "User::find(Auth::id())".
I don't see your posts relationship in your User mode, but still, images are associated for each post.
// Anywhere in your controller
$user = Auth::user();
$posts = $user->posts;
foreach($posts as $post) {
$images = $post->images;
}
So is there no way to return this is one nice array like my original script did? It just did not include the images.
I've even tried the following.
$proofs = User::find(Auth::id())
->posts()
->each(function($row) {
return $row->images()->get();
})
->orderBy('id')
->paginate(15);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community