Laravel pagination, last link generated by $articles->links() return 404
Hi,
I have in controller:
$articles = Article::latest('updated_at')->paginate(6);
return view('mainpage.index', compact('articles'));
In view I have :
@foreach($articles as $article)
{{$article->name}}
@endforeach
{{ $articles->links() }}
It is generating pagination, correct, until , last padinating link is selected, it`s throw 404.
Can anyone help me?
Hi @Brano
Can you paste a
dd($articles);
Also did you alter the /resources/views/vendor/pagination/default.blade.php ? (considering you did a php artisan vendor:publish)
here is $article dump
LengthAwarePaginator {#239 ▼
#total: 17
#lastPage: 3
#items: Collection {#241 ▼
#items: array:6 [▼
0 => Article {#242 ▶}
1 => Article {#243 ▶}
2 => Article {#244 ▶}
3 => Article {#245 ▶}
4 => Article {#246 ▶}
5 => Article {#247 ▶}
]
}
#perPage: 6
#currentPage: 1
#path: "http://localhost/eshop/eshop/public"
#query: []
#fragment: null
#pageName: "page"
}
Please or to participate in this conversation.