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

mariavilaro's avatar

Laravel 5.5 pagination links, how to customize number of elements before ... (three dots)

I know this has been asked thousands of times, but I can only find answers for Laravel versions pre 5.4 and I was wondering if something changed lately. I found this beautiful piece of code in Illuminate\Pagination\LengthAwarePaginator, that builds the elements to show in the pagination links: /** * Get the array of elements to pass to the view. * * @return array */ protect

mariavilaro's avatar
mariavilaro's avatar jlrdw6yrs agoLaravel
2
1
Last reply by jlrdw 6yrs ago
mlazuardy's avatar

Pagination In Category Page Error Call to undefined method

I want to make the pagination inside the sorting list of my category page in localhost:8000/category/slug-name of my category slug name i use method public function show($slug) { // $categories = Category::where('slug',$slug)->first(); if(!$categories){ abort(404);} return view('categories.show')->with('categories',$cat

mlazuardy's avatar
mlazuardy's avatar shawnmilke...8yrs agoLaravel
16
1
Last reply by shawnmilke1 8yrs ago
Shahrukh's avatar

Laravel problem with pagination

I am using laravel pagination for displaying 16 products per page. What happens here is that each product has an images table where a product can have zero or more images. I think the code will define it better. The index method of controller is called for each paginated request public function index() { $products = Product::index(); // Getting Data from products model return v

Shahrukh's avatar
Shahrukh's avatar Shahrukh8yrs agoLaravel
2
1
Last reply by Shahrukh 8yrs ago
ChrisPercival's avatar

Problem with pagination

Hi All I have a problem with pagination & record sets. When all records are listed it works fine, however when I get a record set back and click on the next or any page. The set seems to be lost and all records are shown again. Heres the code in the controller public function index(Request $request) { $listings = Listing::where('published', '=', 2) ->or

ChrisPercival's avatar
ChrisPercival's avatar janakaonto...8yrs agoEloquent
1
1
Last reply by janakaontomatrix 8yrs ago
ronon's avatar

Cache a single post? Cache and pagination?

I have two question related to Laravels Caching System. First: Is it possible to Cache a single post? class PostController{ public function show(Post $post){ // Post need to be cached before it arrives here?!? } } On index I can do. $posts = Cache:rembemer('posts', 60, function(){ return Post::all(); }); Get all posts if they are not in cache. Second:

ronon's avatar
ronon's avatar ronon8yrs agoLaravel
2
1
Last reply by ronon 8yrs ago
ramiawadallah's avatar

Pagination Error

No hint path defined for [pagination].

ramiawadallah's avatar
ramiawadallah's avatar Rajabi7yrs agoLaravel
3
1
Last reply by Rajabi 7yrs ago
Alpha0_0's avatar

pagination not working

Hi, I am new to laravel and i am getting problem when fetching data according to tags with pagination. Can someone assist me right way? But when i paginate it shows errors public function getTagsBySlug($slug){ $tags = Tags::with('posts')->where('tag_slug','=',$slug)->where('tag_status',1)->first(); $data['tags'] = $tags; $data['heading'] = $tags->tag_nam

Alpha0_0's avatar
Alpha0_0's avatar fancyuseri...8yrs agoLaravel
2
1
Last reply by fancyuserid 8yrs ago
dionarap's avatar

Pagination issue with search query

I'm getting an issue where that if i run a search with constraints on a set of data and the returned data is more than my pagination number then when i press on page two of the search results, it returns me to the default query (localhost/page=2) and cancels/ignores the search which had been run. Is there a way around this?

dionarap's avatar
dionarap's avatar toby8yrs agoLaravel
2
1
Last reply by toby 8yrs ago
Samer_J's avatar

Reverse order of pagination?

Using Laravel's pagination feature, is there any way I can reverse the order of the pagination links? Currently it's ordered like this: [<][1][2][3][4][>] And I want it to be ordered like this: [<][4][3][2][1][>] The new content would need to be on the last page (page 4 in my case, instead of page 1).

Samer_J's avatar
Samer_J's avatar JackJones8yrs agoLaravel
2
1
Last reply by JackJones 8yrs ago
Leff7's avatar

Vue pagination not working only in Chrome

I have a pagination component built with Vue 1, for which I am receiving data from Laravel pagination: <template> <div class="row"> <div class="col-md-8"> <div v-if="zeroVideos">No videos found for "{{ query }}""</div> </div> <div class="col-md-8"&

Leff7's avatar
Leff7's avatar TiBian8yrs agoVue
1
1
Last reply by TiBian 8yrs ago
mikoo's avatar

Pagination not showing

Hi guys, I have some code that displays a pagination plugin for jQuery. Everything works fine, however when I add a v-if directive, it does not display. When I inspect the code, it does display in the DOM, but not on the page. No javascript errors, either. <div id="students"> <div v-if="isLoading">

mikoo's avatar
mikoo's avatar mikoo8yrs agoVue
1
1
Last reply by mikoo 8yrs ago
pzl-kleur's avatar

Pagination problem on last page

I have a laravel 5.4.27 application hosted on a linux server that registers owners and their pets, and I'm using laravel's pagination to show the results in groups of 20, but I've been getting this "random" issue on the last page every now and then. There are currently 175 pets registered, using pagination there are a total of 9 pages, the last of which (page 9) canno

pzl-kleur's avatar
pzl-kleur's avatar jlrdw8yrs agoLaravel
1
1
Last reply by jlrdw 8yrs ago
dionarap's avatar

Pagination with Group By

Ive got an issue with my application when i add paginate to the statement, it comes up with an error about my group by. This code works (without pagination): $productsQuery = Product::where('approved', '=', 1)->leftJoin('reviews', 'reviews.products_id', '=', 'products.id')->select('products.*', DB::raw('AVG(ratings) as ratings_average' )) ->groupBy('id') ->orderBy('

dionarap's avatar
dionarap's avatar saurabhd8yrs agoLaravel
5
1
Last reply by saurabhd 8yrs ago
m.alinasab's avatar

how to get posts via category with pagination

hello . i want to get posts from category id ( 1 , 2 , 3 ) and pagination for posts relation . table Stractur : Posts id | title | text category_post relationship category_id | post_id Category id | name my Code is : Category::whereIn('id', [1 , 2 , 3])->with('posts')->paginate() but Pagination Dont work only posts . if posts not exist from relation but pagination is exis

m.alinasab's avatar
m.alinasab's avatar Snapey8yrs agoLaravel
2
1
Last reply by Snapey 8yrs ago
thebigk's avatar

Pagination and parameters other than ?page=x

I'm currently following Jeff's Episode #16 of Building Forum: https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/16 and decided to play with pagination a bit more. I was stuck at pagination where the user filters the thread by username. So I had pagination failing at: https://forum.app/threads?by=JohnDoe&page=3 Pagination failed because the {{ $threads-&

thebigk's avatar
thebigk's avatar gator8yrs agoEloquent
3
6
Last reply by gator 8yrs ago
matthallett's avatar

Pagination with a custom database and implementing toString()

I'm connecting to a database via an ODBC driver. The database uses a slightly different query language (WX2, which is based on Oracle) which doesn't really work with so what I've done is create my own class, service provider and facade to deal with the queries (which I pass in raw format rather than using Eloquent). As I'm dealing with large datasets, I want to paginate. I had

matthallett's avatar
matthallett's avatar mushood8yrs agoLaravel
1
1
Last reply by mushood 8yrs ago
jgravois's avatar

Pagination Woes: losing the $masters->links() functionality

I need some pagination help … I have a table of 12,000+ records and without pagination, it is killing RAM. BUT I have to pass each through a transformer to process before loading and when I do the following I lose the $masters->link(). public function master_control() { $masters = []; $parts = EcoComponentMaster::where('description', '!=', 'DISCARDED')

jgravois's avatar
jgravois's avatar Snapey8yrs agoLaravel
2
1
Last reply by Snapey 8yrs ago
rez's avatar

Pagination in wordpress

I have been working on a personal blog and I cannot get pagination to work. I have been stressed trying to get it to work after months. watching various training series. I am new to php and wordpress. I have evertything working on the first page (first 5 post show). but when i click page two or any other page there is nothing. Post count shows 14 from the query and it has 14 cl

rez's avatar
rez's avatar Snapey8yrs agoCode Review
10
1
Last reply by Snapey 8yrs ago
FinnOP's avatar

Pagination works incorrectly

When I use pagination then I get Page 1 id=10 vote=10 id=2 vote=1 id=3 vote=1 id=4 vote=1 id=5 vote=1 Page 2 id=5 vote=1 id=4 vote=1 id=3 vote=1 id=2 vote=1 id=1 vote=1 I get the same item twice on different pages. These elements are gone id=6 vote=1 id=7 vote=1 id=8 vote=1 id=9 vote=1 If you remove the ->orderBy('votes_count', 'desc') from the query, then the paginati

FinnOP's avatar
FinnOP's avatar FinnOP8yrs agoRequests
7
1
Last reply by FinnOP 8yrs ago
nashultz07's avatar

Pagination with Filters

How would you go about integrating filters with pagination based on https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/14?

nashultz07's avatar
nashultz07's avatar nashultz078yrs agoLaravel
1
1
Last reply by nashultz07 8yrs ago
ronon's avatar

hydrateRaw/fromQuery with pagination?

I currently found out that you can hydrate an Raw sql query. I have following query: DB::table(DB::raw('(SELECT *, Y(location) AS longitude, X(location) AS latitude FROM meetings WHERE MBRCONTAINS(@quadrat, location)) AS sub')) ->select(DB::raw('(FLOOR(SQRT(POW((@ibk_breite - sub.latitude) * 111, 2) + POW((@ibk_laenge - sub.longitude) * 111 * ABS(COS(RADIANS(@ibk

ronon's avatar
ronon's avatar spekkionu8yrs agoLaravel
2
1
Last reply by spekkionu 8yrs ago
Crazylife's avatar

What method can i use to display images together with details and checkbox in pagination?

Is there a better way to show those images details together with checkboxes in grid view and include pagination? Thanks in advance.

Crazylife's avatar
Crazylife's avatar mdecooman8yrs agoGeneral
3
1
Last reply by mdecooman 8yrs ago
0sudesh's avatar

Is there way to make pagination pretty url in Laravel 5.4

Is there a way to get a pagination pretty URL like this (http://localhost:8000/users/all/1). please help me. http://localhost:8000/users/all?page=1 this is how it give me as default Thanks.

0sudesh's avatar
0sudesh's avatar MichalOrav...4yrs agoLaravel
7
1
Last reply by MichalOravec 4yrs ago
Lars-Janssen's avatar

Repository pattern pagination

Hi, Is it fine to return ->paginate(5); (Illuminate\Pagination\LengthAwarePaginator) within a eloquent repository? Right now I've this in my repository: /** * Get Results by Page. * * @param int $page * @param int $limit * @param array $with * @return StdClass Object with $items and $totalItems for pagination */ public function paginate($page = 1, $limit = 10, $with =

Lars-Janssen's avatar
Lars-Janssen's avatar Lars-Janss...8yrs agoLaravel
0
1
Crazylife's avatar

Data from previous pagination link lost after navigate to another page.

I am using laravel lengthawarepaginator. I have a checkboxes with it. When i click a button to select all the check boxes it only check for the first page, and when navigate to another pages then the data from previous page will lost. $("#select-all").click(function(e) { e.preventDefault(); $(':checkbox').each(function() { i

Crazylife's avatar
Crazylife's avatar spekkionu8yrs agoLaravel
3
1
Last reply by spekkionu 8yrs ago
Crazylife's avatar

How to refresh the larabel pagination when filtering data if just refreshing the div content

I am using custom filter to filter my data in a div content <div id="refresh"> <div/> // pagination {{ $lists->links() }} If display all item it will be fined, but if filter the data the pagination number will not be refreshed will remain the page where all data displayed. e.g, there are 3 pages at first after filter it still remain 3 pages if the ac

Crazylife's avatar
Crazylife's avatar Crazylife8yrs agoLaravel
0
1
Sven0188's avatar

Pagination styling classes :: Laravel 5.4

Good day Everyone, I noted that the pagination have a class pagination no-margin pagination-sm which led me to believe somewhere via Laravel / Config one must be able to set the class to: pagination no-margin pagination-md Or do I have to overwrite the style in order to make my pagination buttons larger? And please if I have to - share your views on how :)

Sven0188's avatar
Sven0188's avatar Sven01888yrs agoLaravel
3
1
Last reply by Sven0188 8yrs ago
Joydip's avatar

Looping through custom pagination result works only for first page not the other page?

This is my custom pagination in Laravel 5.4 $currentPage = LengthAwarePaginator::resolveCurrentPage(); if (is_null($currentPage)) {$currentPage = 1;} $collection1 = new Collection($job_ids); $perPage = 20; $currentPageSearchResults = $collection1->slice(($currentPage - 1) * $perPage, $perPage)->all(); $job_ids = new LengthAwarePaginator($currentPa

Joydip's avatar
Joydip's avatar Hawkleaf8yrs agoEloquent
1
1
Last reply by Hawkleaf 8yrs ago
0sudesh's avatar

Laravel pagination pretty url

Is there a way to get a pagination pretty URL like this (http://localhost:8000/users/all/1). please help me. http://localhost:8000/users/all?page=1 this is how it give me as default Thanks.

0sudesh's avatar
0sudesh's avatar 0sudesh8yrs agoLaravel
0
1
Crazylife's avatar

How to refresh a pagination link without loss of css style

I have some custom filter to filter the data, when user select then the div content will be refreshed, but if i refresh the content together with {{$lists->links()}} then during pagination the content will displayed without style. Any solution to fix it? {{$lists->links()}}

Crazylife's avatar
Crazylife's avatar Crazylife8yrs agoLaravel
0
1
charlieBrown's avatar

How to add a button to filter results of pagination

I have followed a tutorial online to build a pagination page but it didn't had anything related to the button. I have made a button to orderBy some fields but when the button is clicked it appends to the end of the URL the &orderBy=<filter> and it keeps adding. HTML code Ordenar por: <a href="{{ Request::url() }}?{{ Request::getQueryString() }}&orderBy=pre

charlieBrown's avatar
charlieBrown's avatar brunofranc...8yrs agoLaravel
2
1
Last reply by brunofrancisco 8yrs ago
andreladocruz's avatar

Scout Pagination acting a little bit strange :)

Hi guys (and girls), I'm using Algolia as my scout engine. I'm calling the search method with this code: $products = Product::search(auth()->user()->client_id .' '. $search)->paginate(\App\DMG\Configuration::getPaginationQty()); \App\DMG\Configuration::getPaginationQty() returns 15. the returning object is this: LengthAwarePaginator {#376 ▼ #total: 16 #lastPage: 2

andreladocruz's avatar
andreladocruz's avatar andreladoc...8yrs agoEloquent
1
1
Last reply by andreladocruz 8yrs ago
P-Torres's avatar

Mailgun, how to implement Mailgun response - pagination on a blade view?

Hi, I'm working with Mailgun's API, I'm trying to implement pagination when displaying the received data. I have the following response from Mailgun. {#383 ▼ +"http_response_body": {#381 ▼ +"items": array:10 [▶] +"paging": {#382 ▼ +"first": "https://api.mailgun.net/v2/lists/[email protected]/members/pages?page=fir

P-Torres's avatar
P-Torres's avatar andrewclar...8yrs agoCode Review
1
1
Last reply by andrewclark 8yrs ago
Crazylife's avatar

value will became null when datatable pagination

I want to save all the value edited by the user. E.g. Value only saved where the pagination is active only, other pages will became null value. How can i ensure value from all pages will be saved. I am using below code to get and store the value get from datatable. {!! Form::open(array('url'=>'storeID/'.$id)) !!} <td>{!! Form::text('max_' . $items->id, old('max', $

Crazylife's avatar
Crazylife's avatar Crazylife9yrs agoLaravel
0
1
abhivachan's avatar

Datatable - Laravel 5.3 Pagination and Search Not working

I am using Laravel 5.3 and Datatable (Yajra). In the datatable, there is no pagination and all records are displaying. Even when i tried to show only 50 entries etc., Search within the datatable is also not working. Please help. Not sure, what i am missing in the code My code is below blade.php $('#btnGetData').click(function () { var filters = $('

abhivachan's avatar
abhivachan's avatar abhivachan9yrs agoLaravel
0
1
firestruck's avatar

Pagination on array

Hi, i need to do pagination in this query: In Eloquent Queries i use $query->paginate(10) But in this query i can´t because it´s an array(even after convert to object , i cant implement ->paginate or ->get(): My code: $results = DB::select('select u.id,u.`name`,r.title, r.start_time, r.end_time, r.estado from `users` u inner join (select user_id, title,start_time, e

firestruck's avatar
firestruck's avatar silverxjoh...9yrs agoEloquent
2
1
Last reply by silverxjohn 9yrs ago
irsyadadl's avatar

Can't use pagination before shortBy

I have project call forum site, I wanna short them by popular with comment count. $topics = Topic::latest() ->withCount('topics') ->paginate(12) ->sortByDesc('topics_count'); The problem is, I can't use pagination on it, when I tried to use $topics->links(), it said if the link method was not founded. So guys. How I can do this while I need to make sure if this ha

irsyadadl's avatar
irsyadadl's avatar tisuchi9yrs agoLaravel
1
1
Last reply by tisuchi 9yrs ago
mnrafg's avatar

Large datasets pagination logic within Laravel views

What view logic will work efficiently for serving as large datasets pagination like Laracasts DSCUSSIONS which is not so much large but I can provide as a sample.

mnrafg's avatar
mnrafg's avatar bashy9yrs agoLaravel
3
1
Last reply by bashy 9yrs ago
jericopulvera's avatar

How do I limit my pagination number buttons to 5?

How do I limit my pagination number buttons to 5? https://jsfiddle.net/z11fe07p/2005/ The pagination here is similar to what I want to accomplish. https://codepen.io/ratiw/pen/GmJayw

jericopulvera's avatar
jericopulvera's avatar abusalameh9yrs agoVue
4
1
Last reply by abusalameh 9yrs ago
Jake2315's avatar

How do I pass pagination in this situation?

I was wondering how I would go about this? Controller: public function index() { $collection = Country::all(); $countries = $collection->slice(4); return view('country.index', [ 'countries' => $countries ]); } View: <div class="row"> <div class="col-md-12">

Jake2315's avatar
Jake2315's avatar tykus9yrs agoCode Review
3
1
Last reply by tykus 9yrs ago
Saikishore's avatar

Laravel scout - get results based on reference table where condition with pagination

Hi Team, I am using "Scout" search. I am having two tables as "users", "user_profile". I am trying to get the users data based on "user_profile.age" = 35 . foreign Key : user_id $users = User::search($keyword)->paginate(4); $users->load(['user_profile' => function ($query) { $query->where('age', 35); }]); Here what happend is

Saikishore's avatar
Saikishore's avatar kishoresai...9yrs agoEloquent
1
1
Last reply by kishoresai438 9yrs ago
Jake2315's avatar

How would I pass pagination to my show method in this situation?

I basically have these thumbnails. Each thumbnail literally 'hasMany country'. I know I'm not passing the pagination to the show action method, but I also don't have a clue how I would go with this either (since I'm using Route Model Binding). My web.php: Route::get("/{thumbnail}/countries", 'CountryController@show'); My CountryController: public function show(Thumbn

Jake2315's avatar
Jake2315's avatar TylerODonn...9yrs agoCode Review
1
1
Last reply by TylerODonnell 9yrs ago
andersonmaths's avatar

Lets-Build-a-Forum-in-Laravel - Lesson 38 - Pagination Issue

I'm finding that I need to make the field in the query string "pages" not "page" in order for the pagination to work. Which is odd given that it works for Jeff in the tutorial. Has anyone else found this? I've had a search around the code for a likely cause, I thought it might be config based but I found nothing. On the forums someone had a similar issue tha

andersonmaths's avatar
andersonmaths's avatar Jaytee9yrs agoLaravel
1
1
Last reply by Jaytee 9yrs ago
joram's avatar

Pagination using JSON API strategy.

I'm trying to implement a JSON API pagination strategy using the Laravel paginator. I'd like to use the query string parameters page[number] and page[size] to request specific page numbers and page size as suggested in the JSON API spec. The paginator will get the page number from the request when the paginators pageName option is specified using the array dot notation (page.nu

joram's avatar
joram's avatar Robstar7yrs agoLaravel
7
1
Last reply by Robstar 7yrs ago
Cronix's avatar

Pagination links

@JeffreyWay It would be nice if the pagination links showed up top as well as below. Often I'll get to a paginated topic that I've already read through, but bc there is a new post in it you have to scroll down past all of the page 1 responses to get to the next page link. Kinda annoying. Ideally it would know the last time you've read the thread and just go to the first new pos

Cronix's avatar
Cronix's avatar Cronix9yrs agoFeedback
0
1
tubbrez's avatar

Laravel 5.2 + Pagination + Multiple DB Table

Hi! Does anybody have an idea of how to do pagination on a page whereby in a data table, i'm displaying data from multiple tables? I've pasted below, the algorithms that i'm using and please note that it is working fine but now i want to add pagination to that page, so does anybody know how i could modify my controller or view so that i can achieve that? Thank you in advance! I

tubbrez's avatar
tubbrez's avatar tubbrez9yrs agoLaravel
2
1
Last reply by tubbrez 9yrs ago
tjkalinowski's avatar

l5scaffold and pagination with bootstrap 4.0

As you probably know pagination is not working in l5scaffold (https://github.com/alnutile/l5scaffold). Original author use Bootstrap 3.x. I wish to use 4.x. Can you share with community how to fix it? In source code command is: {!! $classname->render() !!} At user browser above code is translated to: <ul class="pagination">

tjkalinowski's avatar
tjkalinowski's avatar tjkalinows...9yrs agoLaravel
1
1
Last reply by tjkalinowski 9yrs ago
Lars-Janssen's avatar

SOLID (Liskov substitution) Repository pattern problem with pagination

Hi, I've watched this video on Laracasts. Here is Liskov substitution explained. But how would this work with pagination? I can't just return an array. Thanks a lot

Lars-Janssen's avatar
Lars-Janssen's avatar lars69yrs agoLaravel
1
1
Last reply by lars6 9yrs ago
azimidev's avatar

Pagination with filter helper

Does anyone know how to add pagination for this query where I'm using laravel filter helper function $matches = User::where('gender', auth()->user()->looking_gender) ->ageBetween( auth()->user()->looking_age_from, auth()->user()->looking_age_to ) ->visible() ->confirmed() ->notBlocked() ->latest() ->get()

azimidev's avatar
azimidev's avatar amirhazz9yrs agoLaravel
3
1
Last reply by amirhazz 9yrs ago
cleopatria's avatar

How to use Element ui pagination with Vue JS and Laravel

I'm trying to use element ui pagination with Vue JS and Laravel. It's not changing the data when I clicked next or prev. How to use it properly? <tbody> <tr v-for="post in posts | limitBy count offset"> <td>{{post.id}}</td> <td>{{post.title}}</td> <td>{{post.body | trunCate}}</td> <td v-if="

cleopatria's avatar
cleopatria's avatar ardianck8yrs agoVue
1
1
Last reply by ardianck 8yrs 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.