PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, April 19, 2022

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

 April 19, 2022     laravel, pagination     No comments   

Issue

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

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



Answered By - SaladeDeFruits
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing