Ltloafer's avatar

Displaying image on page 2 of pagination

Hi all,

In my view I'm running a simple foreach loop with an image displayed within. ie

@foreach ($posts as $post) {{$post->thumbnail}} @endforeach

When I use pagination page 1 runs fine, but page 2 onwards won't display the image. What am I doing wrong??

Thanks in advance for any guidance!

Lt

0 likes
4 replies
Sonu's avatar

Is your pagination works fine ? can you show the controller sample code ..

Ltloafer's avatar

Hi Sonu,

The pagination works fine in every other sense.

$posts = Post::orderBy('votes_total', 'DESC')->paginate(15);

    return view('posts.AllPosts')
            ->with('posts',$posts);

The images are displayed okay on page 1, but don't appear on page 2..

Lt

Ltloafer's avatar

Hi,

Figure this out..(apologies as I noticed my first post wasn't correct!)

{{$post->thumbnail}} Needed to be changed to: {{$post->thumbnail}}

Now shows images when on page 2.

Is there a better way than using ../ ?

Please or to participate in this conversation.