Home > Software engineering >  How to solve Call to undefined method App\model\post\::links() error
How to solve Call to undefined method App\model\post\::links() error

Time:04-08

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?

CodePudding user response:

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

  • Related