I am working on a project in laravel 5.3. every thing is gong well but I come to face with a pagination problem in a view. I think, I am missing some thing in code and unable to detect what I have missed.
I have posts
table and a categories
table and another table which stores the the relations of posts and categories its name is post_n_category
. following image show the structure of post_n_category
table.
I have coded the method to fetch data from database whithin the model.
public static function pids($id)
{
$posts = self::select('pid')->where('sid', $id)->orderby('id', 'desc')->paginate(5);
if($posts != null)
{
return $posts;
}
else
{
return "";
}
}
and follwing is the controller method which return view.
public function category()
{
return view('category');
}
and finally following is the view code.
@foreach(\App\PnC::pids(9) as $pid)
{{ $pid->pid }}<br />
@endforeach
<hr />
{{ \App\PnC::pids(9)->links() }}
This code is working correctly, pids display correctly and buttons of paginations are visible as thet should be. but the problem id that when i click on page 2. the url changes correctly but content remain same as first page and the active link of pagination links remain as 1 according the content. so in short the problem is thet on clicking on page number url in address bar chanches correctly but content and active link of pagination links remain same as first page.. so any help please..