'How to solve Call to undefined method App\model\post\::links() error [closed]

I am using laravel paginator and I have this code in my blade if (post -> count()) For each (post as post) {!!$post->title!!} {!!$post->description!!} @endforeach {{$post->links()}}

Am getting Call to undefined method App\model\post::links() error When I inspect in the console the issue am getting is Audit usage of navigator.userAgent, navigator.appversion, and navigator.platform. How can I solve the issue?



Solution 1:[1]

You seem to have an error in your foreach. You wrote For each (post as post) but you probably need something more like foreach($posts as $post). Then, to display the pagination links, use {{ $posts->links() }} (note that the links() method is called on the collection variable, not the individual model).

Check out https://laravel.com/docs/9.x/pagination#displaying-pagination-results

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SaladeDeFruits