Browse AI Field GuideForum Podcast
All ThreadsLeaderboard
  1. Discussions

    1. Popular This Week
    2. Popular All Time
    3. Solved
    4. Unsolved
    5. No Replies Yet

Brano's avatar

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?

Brano's avatar
Brano's avatar Brano9yrs agoLaravel
5
1
Last reply by Brano 9yrs ago
martin.mishat's avatar

How to keep the selected checkboxes checked while pagination?

Greetings, new to Laravel. Using 5.3 and loving it. Having a problem with my checkboxes while pagination. I want to keep the selected checkboxes checked while pagination. Is there any way using 'appends' or 'session' or something else. Codes until now is provided below. Form with a chekcbox: @foreach($cforms as $candidates)

martin.mishat's avatar
martin.mishat's avatar Snapey9yrs agoLaravel
15
2
Last reply by Snapey 9yrs ago
HamsiKafalu's avatar

Pagination not rendering next results

i have a strange problem here which i never had any issues until now when you paginate results and when you click the next page it should return the next results but when i click the next page it just reloads the same page, meaning it displays the same results this is my route Route::group(['prefix' => 'videos'], function () { Route::get('/', 'VideosController@allVideos'

HamsiKafalu's avatar
HamsiKafalu's avatar ajlalhaide...6yrs agoLaravel
7
1
Last reply by ajlalhaider13 6yrs ago
tebowner's avatar

pagination links()

Pagination links() is generating wrong links (http instead of https) ....best way to alter this?

tebowner's avatar
tebowner's avatar mimran9yrs agoEloquent
4
1
Last reply by mimran 9yrs ago
Martha's avatar

blade pagination with api web service

how can I blade the pagination in laravel where data is returned in json format like this: { "total": 3, "per_page": 20, "current_page": 1, "last_page": 1, "from": 1, "to": 3, "data": [ { data data data } } Is there a way other than ajax ?

Martha's avatar
Martha's avatar Martha9yrs agoLaravel
1
1
Last reply by Martha 9yrs ago
shymao's avatar

Pagination Failure

Hello everyone, I manage to make a pagination with every 3 results and write the following code. $news = News::paginate(3)->sortByDesc('updated_at')->toArray(); //write in controller {{ $news->render() }} //write in the blade However it ends up with error and if I only type the code in first line(controller) there won't be error with the page but it can only show with

shymao's avatar
shymao's avatar balasubram...9yrs agoLaravel
6
1
Last reply by balasubramani 9yrs ago
aareyes00's avatar

Pagination add numbers

Hi. I have this pagination got a fiddle from other site <template> <nav class="pagination"> <a class="pagination-previous" @click="paginate('previous')" :disabled="start <= 0">Previous</a> <a class="pagination-next" @click="paginate('next')" :disabled="limit >= total&

aareyes00's avatar
aareyes00's avatar mdecooman9yrs agoVue
1
1
Last reply by mdecooman 9yrs ago
Batis's avatar

Eager Loading with Pagination.

Good day. How to implement pagination with eager loading? With this arrangement, it turns out a lot of requests. $products = Catalogs::with('product.trademark', 'product.image', 'product.property.properties_value.properties_title')->where('category_id', '=', $id)->firstOrFail(); $products = $products->product()->paginate(10);

Batis's avatar
Batis's avatar Batis9yrs agoLaravel
0
1
aareyes00's avatar

VueJS 2 Pagination + Table

Hi anyone, Is there someone who can turn this fiddle to VUEJS2? https://jsfiddle.net/os7hp1cy/48/ I'm trying to create a pagination and table out of this fiddle but it is vuejs ver 1. there's something wrong in v-for

aareyes00's avatar
aareyes00's avatar samfrjn119yrs agoVue
3
1
Last reply by samfrjn11 9yrs ago
madala's avatar

pagination not working

search query public function getAgencyContractsList($n, $searchKey) { /** @var TYPE_NAME $query */ $query = DB::table('wdacs_inv_agcy_contract'); if ($searchKey != '') { $query = $query->whereRaw("(wdacs_inv_agcy_contract.bfy LIKE '%$searchKey%' OR wdacs_inv_agcy_contract.ecaps_unit_cd LIKE '%$searchKey%' OR wdacs_inv_agcy_contract

madala's avatar
madala's avatar jlrdw9yrs agoLaravel
2
1
Last reply by jlrdw 9yrs ago
Ifrit's avatar

Creating pagination

I'm trying to create a comment section that has pagination. The error I'm getting is this FatalErrorException in OpenController.php line 118: Call to a member function paginate() on array My OpenController <?php namespace App\Modules\Open\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; use Illuminate\Support\Fac

Ifrit's avatar
Ifrit's avatar Ifrit9yrs agoLaravel
5
1
Last reply by Ifrit 9yrs ago
martin.mishat's avatar

How to keep the selected checkboxes checked while pagination?

Greetings, new to Laravel. Using 5.3 and loving it. Having a problem with my checkboxes while pagination. I want to keep the selected checkboxes checked while pagination. Is there any way using 'appends' or 'session' or something else. Codes until now is provided below. Form with a chekcbox: <form id="cforms" method="post">

martin.mishat's avatar
martin.mishat's avatar martin.mis...9yrs agoLaravel
2
1
Last reply by martin.mishat 9yrs ago
Alzaabi98's avatar

pagination with filtering - issue in pagination goes back to unfiltered data

Hi all, I want to show all records in index.blade.php, at the same time I wan to allow users to filter results based in certain criteria such as country etc. I was able to implement filter and pagination but I have once issue : When the user filter something , pagination does not pick the filtered result except in page #1. Then it will go back to unfiltered data, here is the co

Alzaabi98's avatar
Alzaabi98's avatar Alzaabi989yrs agoEloquent
6
1
Last reply by Alzaabi98 9yrs ago
hillcow's avatar

How to handle big database queries with pagination in Laravel 5

Hey, say I had a forum with more than a million threads, how would I approach showing these threads with pagination ordered by a column 'hot' that includes an integer? I couldn't simply do Thread::orderBy('hot', 'desc')->paginate(20) since this query would have to go through the whole million threads. Thank you very much!

hillcow's avatar
hillcow's avatar jlrdw9yrs agoEloquent
1
1
Last reply by jlrdw 9yrs ago
ekrist1's avatar

Eloquent query with pagination

I have implementet query string filtering using the laracast session (https://laracasts.com/series/eloquent-techniques/episodes/4). I´m able to add pagination to the result, but how can I add pagination together with the query string? Now the next_url shows http://laravel.dev/api/getcontacts?page=2 regardless your have a query string like: http://laravel.dev/api/getcontacts?key

ekrist1's avatar
ekrist1's avatar ekrist19yrs agoEloquent
1
1
Last reply by ekrist1 9yrs ago
JuD3's avatar

Ajax Update Existing Pagination

Hi Community Fairly new to Laravel and wanted to know how I would update Laravels Pagination in Javascript. If that is at all possible and how to go about it

JuD3's avatar
JuD3's avatar JuD39yrs agoLaravel
4
1
Last reply by JuD3 9yrs ago
TheRealJAG's avatar

Pagination links() method doesn't exist after sortByDesc on hasMany

While writing a "Top" questions page in my app today I noticed that pagination isn't working ("Method links does not exist. ") when I sort on a hasMany relationship. /** * Returns relevant questions sorted by vote according to the tag object * @param $tags - Tags object returned from get_tags() * @return mixed */ public static fun

TheRealJAG's avatar
TheRealJAG's avatar vipin939yrs agoLaravel
7
1
Last reply by vipin93 9yrs ago
Abi's avatar

Ajax Laravel Pagination jQuery Plugin - JSON

I just wanted to share a little plugin that I've done for Ajax pagination at the moment it only works with Json. I'll be making one for vueJs aswell. I hope you guys like it. https://github.com/abisalazar1/laravel-content-loader

Abi's avatar
Abi's avatar Abi9yrs agoTips
0
1
cowzo's avatar

Incorrect pagination results

Hi all, I have a question about the pagination and I hope someone can help me out. Currently I have a single page with filter options. Based on these filters the results are being rendered. This is my Controller code: $from = urldecode($request->input('vanaf')); $to = urldecode($request->input('tot')); $count = 0; $partijen = Partij::with(['aanvoertransactie' => funct

cowzo's avatar
cowzo's avatar cowzo9yrs agoLaravel
4
1
Last reply by cowzo 9yrs ago
Leff7's avatar

Vue pagination creates pagination links starting from 0

I am following a tutorial on Vue and Laravel pagination. I am creating pagination links based on the data that I get from the backend, by parsing pagination.total_pages. <li v-for="page in parseInt(pagination.total_pages)" class="page-item" v-bind:class="{ 'active': paginatio

Leff7's avatar
Leff7's avatar Drax79yrs agoVue
2
1
Last reply by Drax7 9yrs ago
dominykasgel's avatar

Laravel 5.3 - How to make pagination URLs pretty?

I'm surprised there's no out of the box solution or I couldn't find it. I want to have /page/2 instead of ?page=2. Has anyone tried to make the pagination URLs pretty in Laravel 5.3-5.4? My code looks like: Controller: $products = Products::orderBy('date', 'desc')->paginate(20); View: Using a custom pagination view: foreach and ... $paginator->url($i) .

dominykasgel's avatar
dominykasgel's avatar quanghuy12...9yrs agoLaravel
1
1
Last reply by quanghuy1294 9yrs ago
Leff7's avatar

Laravel 5.3 - Multiple pagination in a single view

I am displaying paginated results that I get from Algolia. I have two queries in my controller that I paginate. This is how I send the data from the controller to the view: public function index(Request $request) { if(!$request->q && !$request->page){ return redirect('/'); } $videos = Video::search($request->q)->paginate(1); $videosCol

Leff7's avatar
Leff7's avatar Snapey8yrs agoLaravel
2
1
Last reply by Snapey 8yrs ago
scottjo's avatar

Remembering Pagination Page

Hi folks Apologies if this has been asked before but I feel I must be missing something straightforward in respect to pagination. I have an administration page with a paginated set of data which works a treat. Each row has a link that goes off to an edit page - nothing very exciting here. The user returns back to the index page - either by cancel or saving changes etc. and I us

scottjo's avatar
scottjo's avatar scottjo9yrs agoLaravel
2
1
Last reply by scottjo 9yrs ago
KhalilurRehman's avatar

Pagination not working in laravel 5.3 with for loop iteration. Pagination object is being hide when i use for loop or foreach loop

Pagination is working without use of for loop, when want to do structuring with data using for or foreach loop, pagination is being hide from response. here is my code. Pagination object is being hide when i use for loop or foreach loop. $calls = DB::table('call') ->where('call.company_id', '=', $company_id) ->orderBy('call.created_at', 'ASC') ->paginate($perPage, arra

KhalilurRehman's avatar
KhalilurRehman's avatar SaeedPrez9yrs agoLaravel
3
1
Last reply by SaeedPrez 9yrs ago
insight's avatar

How to separate two pagination links which came from single controller method ?

Dear Friends, I am using Laravel 5.3. I created two similar paginations in my Home page using Controller method here : http://kopy.io/zddOe My index.blade.php file is : http://kopy.io/528Ar The problem is when I click the pagination of one item , the other page too also change. Please suggest a simple method to fix this problem without affect another.. Waiting fast reply. Thank

insight's avatar
insight's avatar SaeedPrez9yrs agoLaravel
4
1
Last reply by SaeedPrez 9yrs ago
anhnd's avatar

Problems with pagination when building a SPA with vuejs using vue-router

Hi all, I got a problem when building SPA with vuejs using vue-router. Everything works great without pagination. But when i go to next page. It is not update new Route Somebody helps me out, please! Here is my code: <template> <div class="category-view"> <topic v-for="topic in topics" :topic="t

anhnd's avatar
anhnd's avatar anhnd9yrs agoVue
8
1
Last reply by anhnd 9yrs ago
shamon's avatar

Laravel 5.3 :manual pagination with custom array not displaying links in page

I am trying to implement a manual pagination with custom array in Laravel everything works fine except with the pagination links. Pagination links not displayed in the page Controller $perPage = 3; $currentPage = Input::get('page',1)-1; $pagedData = array_slice($this->data->arts->toArray(),$currentPage*$perPage,$perPag

shamon's avatar
shamon's avatar shamon9yrs agoLaravel
0
1
princelionelnzi's avatar

Load Laravel pagination links using AJAX

I am having the following code which is working partially. var pagination_links = '<ul class="pagination">'; if (json.current_page == 1) { pagination_links = pagination_links + '<li class="disabled"><span>&laquo;</span></li>'; }else { pagination_links =

princelionelnzi's avatar
princelionelnzi's avatar princelion...9yrs agoLaravel
0
1
danieln's avatar

Laravel pagination links not working

I have this code on the view that is displaying for pagination correctly {{$products->links()}} The link created are correct: http://demo.com/default?page=2 However, the items that is listed remains to be on the first page only. Could there be anything wrong? FYI, in the controller I have this to generate the data $products = \App\Product::paginate(1);

danieln's avatar
danieln's avatar ashish262yrs agoLaravel
50
1
Last reply by ashish26 2yrs ago
MrRobot21's avatar

Laravel 5.3 API Pagination

Hi Awesome People i'm working on an API, and i'm stuck at pagination first i should send only first 10 records later based on the limit value passed by user i should send the next 10 records so for i did this //search Drivers public function getSearchList($limit) { //dd($limit); $drivers = Driver::paginate($limit); ->select('id

MrRobot21's avatar
MrRobot21's avatar meSingh9yrs agoLaravel
1
1
Last reply by meSingh 9yrs ago
evanzyl's avatar

Pagination in laravel

Good day Is there anybody that can help me with adding pagination to laravel 5? I inherited a site and not sure how to add it. This is the function: Route::get('/bookings', array( 'as' => 'private-bookings', function () { //show the page: $viewData = array( 'metaTitle' => 'Bookings | ' . config('app.name'), 'metaSectionJ

evanzyl's avatar
evanzyl's avatar evanzyl9yrs agoLaravel
2
1
Last reply by evanzyl 9yrs ago
Aspex's avatar

Laravel - Fractal Pagination issue with Vue: accessing Meta -object fails

Hi, I'm running Laravel 5.3 on Homestead and trying to get Fractal Pagination work with Vue.js. However, I've run in issues trying to refer to "meta" object returned in the "response" from my backend. For some reason I can refer to e.g. user.name in my vue just fine, but have apparently no skills to access the fractal's "meta"-part. Say, if I try

Aspex's avatar
Aspex's avatar Vellu9yrs agoVue
1
1
Last reply by Vellu 9yrs ago
sherwinmdev's avatar

pagination for query builder and stored procedure

i can't seem to figure out how to get pagination to work on query builder with stored procedure. it returns an array and not a collection so i can't use ->paginate(). i found this post but i don't know how to incorporate it to my code http://itsolutionstuff.com/post/mysql-procedure-with-pagination-in-laravel-5example.html. here's what i have. controller public function index

sherwinmdev's avatar
sherwinmdev's avatar osmalose5yrs agoGeneral
6
1
Last reply by osmalose 5yrs ago
orange_adrenalin's avatar

How to create Pagination from json

Hi, I have 2 site on Laravel. I get information about catalog of products by API from first site with pagination data. How to unserialze (or create) pagination template on second site from JSON ? When I create class \Illuminate\Pagination\Paginator from json. They have only one page with itmes, wich lie in data property.

orange_adrenalin's avatar
orange_adrenalin's avatar orange_adr...9yrs agoLaravel
1
1
Last reply by orange_adrenalin 9yrs ago
minster's avatar

Eager Loading with Pagination

Hi guys , Im learning Laravel and I have followed the Laravel from scratch series to setup a hotel review app. Im loading the hotels reviews using Lazy Loading and its an eloquent relationship but I cant get pagination to work. Ive tried this and it doesnt work : $hotel->load('reviews.user')->paginate(5); Hopefully someone can help me out.

minster's avatar
minster's avatar minster9yrs agoEloquent
0
1
jreco's avatar

laravel pagination error

i want paginate a array with LengthAwarePaginator in Laravel. when i try navigate between pages, laravel show this error: NotFoundHttpException in RouteCollection.php line 161 mi code are: //$queries1 is an array. $currentPage = LengthAwarePaginator::resolveCurrentPage(); $collection = new Collection($queries1); $currentPageSearchResults = $collection->slice

jreco's avatar
jreco's avatar Rama63129yrs agoLaravel
1
1
Last reply by Rama6312 9yrs ago
Waldemar's avatar

Filtered Data with pagination

Hi! Filter products work is fine, and pagination work is fine too. But when i first filter data and then try paginate filter droped Filter data and paginate i need see url as ?brands%5B%5D=2&page=2 but when i paginate filtered data i have url ?page=2 Filter is gone HTML @section('filters') <div class="sidebar-module-container"> <h3 class="sect

Waldemar's avatar
Waldemar's avatar Deamonik9yrs agoLaravel
9
1
Last reply by Deamonik 9yrs ago
kickthemooon's avatar

Redis and pagination

I am starting off with redis. This is my controller: public function index(){ $currentPage = Input::get('page') ? Input::get('page') : '1'; $articles = $this->remember('articles.paginate.'.$currentPage, 3, function(){ return json_encode(Article::orderBy('id', 'desc')->with('categories')->paginate(20)); }); return view('ind

kickthemooon's avatar
kickthemooon's avatar kickthemoo...9yrs agoLaravel
3
1
Last reply by kickthemooon 9yrs ago
cyberfountain's avatar

Data filtering with pagination and Vue.js

Hello, I am facing a challenge. I have a very simple app. I need to return results from the table in a list - table contains around 7 000 records. I need to paginate results displaying around 25 records a the time. That's all seems to be easy. Now is a part a can't get my head round. I need to be able to filter through the table records all 7 000. Simple 2 way data binding and

cyberfountain's avatar
cyberfountain's avatar Benja8yrs agoLaravel
5
1
Last reply by Benja 8yrs ago
minedun6's avatar

Datatable Pagination stuck after search

Hi, I've made a quick video showcasing my problem so that everyone can see it better. Pagination stays the same after search As you can see, the problem is that when I navigate to the next set of data and I do a search, the current_page stays at page "2". Problem is that it's not the kind of behaviour I need. Here's the code, Watch out, it's pretty long: <template&

minedun6's avatar
minedun6's avatar ratiw9yrs agoVue
3
1
Last reply by ratiw 9yrs ago
gabriel007's avatar

Laravel 5.2 - over the range pagination numbers in URL producing a blank page

I did a good search before posting - but cannot figure out a way to prevent users from manually inputting page numbers in the URL of the paginator (a number over that range producing a blank page). For example page 2 would have the following link: http://localhost/articles?page=2 If I have a maximum of 3 pages, and manually changing 2 into 5 within the URL, this will be redire

gabriel007's avatar
gabriel007's avatar rujul046yrs agoLaravel
5
1
Last reply by rujul04 6yrs ago
newbie's avatar

pagination in laravel

how to make a pagination in order to make my data not too long in the page

newbie's avatar
newbie's avatar willvincen...9yrs agoLaravel
3
1
Last reply by willvincent 9yrs ago
RaiderRAFC's avatar

Pagination with last row lookup

Hey everyone, I have a table with about 2.7 million rows which I want to paginate. However because of the size of the table I'm running against the late row caveat: how higher the page, how slower the load times. I've come accross a couple of threads which speak of the following trick: SELECT t.* FROM ( SELECT id FROM mytable ORDER BY

RaiderRAFC's avatar
RaiderRAFC's avatar jlrdw9yrs agoLaravel
1
1
Last reply by jlrdw 9yrs ago
nikocraft's avatar

pagination when using post instead of get, is it possible?

I have a form that is using post, when I submit it I get results and pagination back. However when I clicked on pagination links I get: MethodNotAllowedHttpException in RouteCollection.php line 218: in RouteCollection.php line 218 at RouteCollection->methodNotAllowed(array('POST')) in RouteCollection.php line 205 So its not possible to have pagination when using pos

nikocraft's avatar
nikocraft's avatar maxnb9yrs agoLaravel
1
1
Last reply by maxnb 9yrs ago
Firemaps's avatar

Reverse pagination

I am building a reversed pagination from a one to many relationship 1 user has many photos Currently the ID's are coming out Page 1 = 10, 9, 8... Page 2 = 19, 18, 17 How can I make page 1 the most recent = 19, 18, 17... and page 2 = 10, 9, 8...? In my blade file where the photos are being displayed I am looping through all of the users photos to display them @foreach($user->

Firemaps's avatar
Firemaps's avatar willvincen...9yrs agoGeneral
1
1
Last reply by willvincent 9yrs ago
Vija's avatar

How to show pagination in listing record

Can you please guide me how can i show pagination in listing view. Route: Route::get('business/products',['as' => 'product-list', 'uses' => 'ProductController@productList']); Controller: public function productList(Request $request) { Session::put('product_field', Input::has('field') ? Input::get('field') : (Session::has('product_field') ? Session::get('product_field'

Vija's avatar
Vija's avatar Vija9yrs agoCode Review
2
1
Last reply by Vija 9yrs ago
Cryank's avatar

Using scope and pagination in a accessor ?

Hello everyone , I have a question about using Scope, Paginate, and HasMany Relationship together... In a Batch Model /** * A Batch has many applicants * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function applicants() { return $this->hasMany('App\Applicant'); } By relationship defined, I can access Ap

Cryank's avatar
Cryank's avatar Cryank9yrs agoEloquent
7
2
Last reply by Cryank 9yrs ago
rocoo's avatar

Pagination with many to many

Hello, I'm having issues figuring out how to paginate a many to many relationship. I'm trying to get create a forum app similar to this one here. I attempted to paginate questions asked on a forum with specific tags eg. /discuss/tags/laravel Question Model: public function tags() { return $this->belongsToMany('App\Tag'); } Tag Model: public function ques

rocoo's avatar
rocoo's avatar rocoo9yrs agoLaravel
2
1
Last reply by rocoo 9yrs ago
murilo's avatar

Laravel Many to Many with Pagination

Hello guys , I don´t know if some one can help me . I did a many to many Laravel relation ship in a Post Table and in a Tags Table . Like this example - https://laracasts.com/series/laravel-5-fundamentals/episodes/21 It worked fine , but I want to find and paginate all the POST that has a TAG selected , like this - www.mywebsite.com/posts?tag=4 So I did a many to many

murilo's avatar
murilo's avatar murilo9yrs agoEloquent
4
1
Last reply by murilo 9yrs ago
b4nghh's avatar

Laravel 5.3 pagination problem with last page

Currently, I'm working on a Laravel 5.3 project. I'm facing a problem with pagination on the last page. If the last page has more than one item, it will work normally. But if it has only one item, pagination links will disappear. This is some screenshots: The last page has more than 1 item: http://prntscr.com/co5fdf The last page has only 1 item (pagination links disappear): h

b4nghh's avatar
b4nghh's avatar b4nghh9yrs agoLaravel
3
1
Last reply by b4nghh 9yrs ago

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.

Learn
BrowseSeriesCreatorSeriesLaravel PathLarabitsPlayground
Discuss
ForumPodcastSupport
Extras
Gift CertificatesApparelFAQiOS AppTerms
Social
X(Twitter)TikTokYoutube

© Laracasts 2026. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.