How can i use next() or current() in laravel eloquent returned array?

Solution:

$posts = Post::all(); // returns a collection

You want

$posts = Post::all()->toArray();

You can then call current($posts) or next($posts) or prev($posts) or end($posts).

But as you have a collection, you could always use laravel’s collection methods such as firstlasteachfiltermapreduce etc.

https://laravel.com/docs/5.4/eloquent-collections#available-methods