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

boyanr's avatar

Strange issue with pagination

This works: $invoices = Invoice::orderBy('id','desc')->paginate(20); But if I change it to this it gives an error at Builder::links(): $invoices = Invoice::orderBy('id','desc'); $invoices->paginate(20); Any ideas? I need it separated, because I'm going to add some dynamic where clauses in the middle...

boyanr's avatar
boyanr's avatar boyanr9yrs agoEloquent
1
1
Last reply by boyanr 9yrs ago
kekekiw123's avatar

Laravel pagination returns links in http and not https

I am using the ->paginate(20); function on my query but the only problem is that it will return http and not https Eg: "next_page_url":"http://www.mysite" I have tried to force my app to use https by adding this in AppServiceProvider public function boot() { if (!\App::environment('local')) { \URL::forceSchema('https'); }

kekekiw123's avatar
kekekiw123's avatar ArthurYdal...1yr agoLaravel
12
3
Last reply by ArthurYdalgo 1yr ago
socieboy's avatar

Pagination filesystem

Is there some way to paginate the files on the storage from amazon s3 or local?

socieboy's avatar
socieboy's avatar ohffs9yrs agoLaravel
1
1
Last reply by ohffs 9yrs ago
sefran's avatar

Laravel 5.2 - inRandomOrder() and pagination: is there an alternative to orderBy(DB::raw('RAND(aseed)')

I have to display posts on multiple pages, but I want the order be always different. Unfortunately inRandomOrder() can give already displayed items by requesting another page. orderBy(DB::raw('RAND(aseed)') or orderByRaw('RAND(aseed)') are database specific and slow on a big dataset. What could be an efficient alternative?

sefran's avatar
sefran's avatar sefran9yrs agoEloquent
2
1
Last reply by sefran 9yrs ago
MinZaw's avatar

pagination by array data

how to paginate my data from array, my data have in array,i donot use database, i just use array to pagination,please help all,

MinZaw's avatar
MinZaw's avatar Dimoff9yrs agoLaravel
1
1
Last reply by Dimoff 9yrs ago
sl0wik's avatar

Merge and pagination of scout search results.

I have two scout search results (elastic), I need to merge them and paginate - is it possible with paginate()?

sl0wik's avatar
sl0wik's avatar sl0wik9yrs agoGeneral
0
1
melkhior's avatar

Pagination of N level hierarchy category system in tree view

I currently have a N level hierarchy category system (Category model), and a coin system (Coin model), I have a page that shows all the categories and coins in a tree view. But since there is a lot of coins, is there a way to paginate it all based on the amount of coins?, Say, limit it to around 50 coins a page. Can't think of any proper way to do it since there can be infinite

melkhior's avatar
melkhior's avatar melkhior9yrs agoLaravel
14
1
Last reply by melkhior 9yrs ago
murilo's avatar

Laravel Pagination with Eloquent does not Work

Hello , I'm trying to paginate with eloquent but I am no been success . If I paginate like this , It will works - $messages = Messages::orderBy('created_at', 'desc')->paginate(10); But if I try to get all the messages from a user and paginate it , like this - $messages = $this->user->Messages->paginate(10); It will not paginate , some one know a better way to

murilo's avatar
murilo's avatar murilo9yrs agoEloquent
7
1
Last reply by murilo 9yrs ago
Mohsen's avatar

Laravel lazy eager loading with pagination

Hi I have two models , Tag and Post and many to many relation between them . I want to show and also paginate posts with specific tag . what is the best practice for this situation . I used the function but not work : public function getPosts($tagId,$rowsCount) { return App\Models\Tag::where('id',$tagId)->with(['posts' => function($q) use (

Mohsen's avatar
Mohsen's avatar Mohsen9yrs agoEloquent
2
1
Last reply by Mohsen 9yrs ago
sharlie's avatar

Laravel Scout Pagination returning incomplete results

I am using Scout to create a search with Algolia as the driver. Everything is synced and returning results, but when I set the results to be paginated, The paginated results is incomplete. Depending on the search term, the array indexes will be 0, 1, 2, 5, 6, 8, 9. Notice how the array is missing 3, 4, and 7. So when I display the results on the frontend, it is only showing 7 r

sharlie's avatar
sharlie's avatar sharlie9yrs agoLaravel
0
1
kossa's avatar

Load with pagination

Hi, Let's say, I want to load 15 posts for a user : $user = User::first(); $user->load(['posts' => function($q){ $q->paginate(); }]) ; I get array of posts, not page

kossa's avatar
kossa's avatar Bilalfarha...9yrs agoEloquent
3
1
Last reply by Bilalfarhat24 9yrs ago
Lars-Janssen's avatar

Eager loading pagination

Hello, I've got this in my webapp: $forum->load('topics'); It returns all related topics from a forum. But how would I paginate the topics?

Lars-Janssen's avatar
Lars-Janssen's avatar SaeedPrez9yrs agoLaravel
6
1
Last reply by SaeedPrez 9yrs ago
Lars-Janssen's avatar

Laravel pagination with dropdown

Hello, I've got a route that returns Software::paginate(15);. So what is the best practice if I want to show all software items within a dropdown menu? Should I make a separate route that returns Software::alll(); or are there better ways of handling this? Thanks!

Lars-Janssen's avatar
Lars-Janssen's avatar devamit201...8yrs agoCode Review
6
1
Last reply by devamit2018 8yrs ago
YanTao's avatar

How to transformer the pagination data

I want to transformer the paginaton data , but it doesn't work. $sort = $request->sort; $filter = $request->filter; $perPage = $request->per_page; $devis= $this->devisInterface->getAll($sort, $filter, $perPage); return $this->respondWithCollection($devis,new DevisTransformer());

YanTao's avatar
YanTao's avatar YanTao9yrs agoLaravel
2
1
Last reply by YanTao 9yrs ago
Mohsen's avatar

Pagination With Many to Many Relation

I have tow models with many to many relationship . posts and tags (tag labels for each post). I tried to paginate posts with this code in repository but doesn't work . what this the problem ? public function getTagsWithPosts($tagId,$rowsCount) { return $this->tag->where('id',$tagId)->with(['posts' => function($q) use ($rowsCount){ $q->

Mohsen's avatar
Mohsen's avatar tomi9yrs agoLaravel
3
1
Last reply by tomi 9yrs ago
david.bruenner@t-online.de's avatar

Pagination with ajax not working

I´m using Laravel5.3. The problem is that the current Pagenum is not set. I mean I get the correct data in the ajax call but in the subtemplate of the paginator there is a piece of code deciding wheter to disable current link or not. @if ($paginator->onFirstPage()) <li class="disable"><span>«</span></li> @else <li><a href=

david.bruenner@t-online.de's avatar
david.bruenner@t-online.de's avatar david.brue...9yrs agoLaravel
1
1
Last reply by [email protected] 9yrs ago
chibyke's avatar

Ajax like Pagination

Please i have three different paginated tables on my page and i noticed that when i click on the next link in one of the tables, it affects the other tables. that is, their view will change. But that is not what i want. I want the content of the other tables to remain the when i click on any of the other tables. I know i can use jquery ajax to achieve this but am returning a mo

chibyke's avatar
chibyke's avatar chibyke9yrs agoEloquent
0
1
Belio's avatar

Returning only the items from the last page in pagination

Hello everyone. This code bellow it is working fine, but now I want to return it in reverse. I mean, return only the items from the last page so I can set as active order the last one I stored. public function store(Request $request) { $order = new Order($request->all()); Auth::user()->orders()->save($order); $orders = Order::with('lines', 'tab

Belio's avatar
Belio's avatar disitec9yrs agoCode Review
2
1
Last reply by disitec 9yrs ago
pag66's avatar

Pagination and filter

Hello everyone, I have a filter for my users, based on some criterias, but when I choose the second filter page it doesn't display anything, what I'm doing wrong ? Thanks for the help Here is my Controller filter function. public function filter(Request $request){ $clinica = Clinica::first(); // filtrado por valor apellido if ($request->has(

pag66's avatar
pag66's avatar JavierSoli...7yrs agoLaravel
10
1
Last reply by JavierSolis 7yrs ago
minortechnologies's avatar

Raw Query with Location, Join, and Pagination

I am using Laravel 5 to build functionality to allow a user to search for specials from vendors that are near their location. I have a table that holds vendors with their locations and another table that holds specials that vendors are offering. The specials table has a vendor_id column to link to the vendors table. vendors (id, name, latitude, longitude) - some fields omit

minortechnologies's avatar
minortechnologies's avatar minortechn...9yrs agoEloquent
0
1
kossa's avatar

Pagination under load function (eager loading)

Hi, I'm building a Rest API, I have to return all categories, and under each category I want to retrieve 15 articles, I have 2 models Category and Article, my code is : $categories = Category::where('somthing', $something)->get(); return $categories->load(['articles' => function($q) { $q->latest()->paginate() }]); The problem I get only 15 of first categori

kossa's avatar
kossa's avatar d3xt3r9yrs agoLaravel
4
1
Last reply by d3xt3r 9yrs ago
KHAN's avatar

L5 Ajax Pagination And Maintaining Filtering/Sorting Data

solved

KHAN's avatar
KHAN's avatar KHAN9yrs agoLaravel
2
1
Last reply by KHAN 9yrs ago
AdamEsterle's avatar

Unions, Pagination, and Sorting

So it looks like unions and paginations cannot be done with Laravel? Please let me know if I am wrong. Problem: I am trying to display a list of Picture and Video objects ordered by 'created_at' Temporary solution: Get Collection of all Pictures, Collection of all Videos and do a "push" on them and sortByDesc('created_at') Then I do a ->forPage($page, $perPage) and

AdamEsterle's avatar
AdamEsterle's avatar AdamEsterl...9yrs agoEloquent
4
1
Last reply by AdamEsterle 9yrs ago
spodlogar's avatar

Laravel Pagination

How can I use a different paginator in my Laravel view? It seems to default to the Bootstrap 3 Presenter and I would like to use the Bootstrap 4 Presenter.

spodlogar's avatar
spodlogar's avatar spodlogar9yrs agoLaravel
6
1
Last reply by spodlogar 9yrs ago
Kryptonit3's avatar

URL query strings not working (pagination)

I built a warehouse management site for my previous company and they have recently expanded into another market. I had the original site on the base domain https://gandc.co now that they have opened a shop in another market I moved the base domain code to a subdomain https://louisville.gandc.co - The site 99% works as it should. I did migrate all the code to a new digital ocean

Kryptonit3's avatar
Kryptonit3's avatar Kryptonit39yrs agoLaravel
1
1
Last reply by Kryptonit3 9yrs ago
ronit5rg's avatar

What to write in nextSelector of jScroll for infinite scrolling with laravel 5 pagination?

I am quite new to Laravel and jQuery, so maybe this is a silly question. I am stuck and I don't know what to write in the nextSelector section of jScroll. nextSelector is supposed to contain the link to the next page, and I am using paginate() of laravel. I am trying to get infinite scrolling for the posts. This is my home.blade.php which contains the posts and the script for j

ronit5rg's avatar
ronit5rg's avatar ronit5rg9yrs agoCode Review
0
1
mergodon's avatar

Map pagination collection best practice?

Is there any better way to do something like this? I would like to pre-map some stuff in my controller, instead putting it into the view: $articles = $articles ->paginate(15) ->appends(request()->all()); $articles->setCollection( $articles->getCollection() ->map(function($item, $key) { $item-

mergodon's avatar
mergodon's avatar Ortzinator4yrs agoCode Review
6
5
Last reply by Ortzinator 4yrs ago
chinatown's avatar

Eloquent HasManyThough ForeignKey key and pagination pro

I have three tables: Videos: -id -name -another fields Cats: -id -name -another fields Cats_videos: -id -cat_id -video_id And three Eloquent models (cats has AllCatVideos() function ): public function AllCatVideos() { return $this->hasManyThrough('App\videos', 'App\cats_videos','cat_id','id'); } So, I want to receive all videos in one cat and then paginate the results.

chinatown's avatar
chinatown's avatar chinatown10yrs agoEloquent
1
1
Last reply by chinatown 10yrs ago
APPLE199's avatar

Find out which page has a specific record in pagination?

I'm working on a "forum like" app and when viewing a thread, a user can also choose to view a post in a thread (an specific one). The URL can be something like /thread/29?post=22. Now, a thread can have many posts. Therefore, since it's paginated with 10 posts per page, a post can be in any page depending on when it was posted. I have no way of knowing which page the

APPLE199's avatar
APPLE199's avatar APPLE19910yrs agoGeneral
5
1
Last reply by APPLE199 10yrs ago
BrianDillingham's avatar

Method render does not exist. Eager / Nested Pagination

I am only getting the amount I set in paginate() ie 4 snippets & 15 likes but in the view I call $user->snippets->render() and get Method render does not exist Any help would be much appreciated $user->load([ 'snippets' => function ($query) { $query->paginate(4); }, 'likes' => function ($query) { $query->paginate(15); }, ]); dd($user->sni

BrianDillingham's avatar
BrianDillingham's avatar wiedem10yrs agoCode Review
6
1
Last reply by wiedem 10yrs ago
Ishatanjeeb's avatar

Laravel 5.2 Pagination

I just fetch all post that user posted now I want to use paginate.Can anyone help? PageController $user = Auth::user(); $allPost = $user->posts; return view('admin.index', compact('allPost'));

Ishatanjeeb's avatar
Ishatanjeeb's avatar wiedem10yrs agoLaravel
1
1
Last reply by wiedem 10yrs ago
visyonDevelopers's avatar

Custom pagination (variable quantity of items per page)

I was wondering if there is some example out there about how to implement a paginator which shows 'n' results on first page and then 'm' on following pages (being 'n' > 'm'). The app I'm developing has no views (its responses will be JSON objects), so my concerns aren't on how to implement a Presenter, but some way to be able to show a certain amount of items on the first pa

visyonDevelopers's avatar
visyonDevelopers's avatar mariavilar...8yrs agoLaravel
5
1
Last reply by mariavilaro 8yrs ago
ItsMrSammeh's avatar

Eloquent Question / Pagination

Hey guys. So basically, I have an int connected to my main user account, which will determine, which client they are under in our application(Which client they are working with in the business) Each account can have multiple youtube channels added to them, and in one of the parts of our application, we need to grab all youtube accounts, via the clients MASTER client(The user th

ItsMrSammeh's avatar
ItsMrSammeh's avatar Rwendel10yrs agoLaravel
2
1
Last reply by Rwendel 10yrs ago
Auxano's avatar

Error in pagination

I am having a problem with paginator in laravel 5.2 ,I get error BadMethodCallException in Macroable.php line 81: Method links does not exist. This happens when i use {!! $posts->links()!!} in my view page.How do i resolve this?

Auxano's avatar
Auxano's avatar Auxano10yrs agoGeneral
0
1
jrdavidson's avatar

Datatables and Laravel Pagination

Is there any thoughts as to what advantages/disadvantages there are to when grabbing let's say users from a database and paginating them with Laravel or looping through them in a table and rendering the table as a Datatable with the Datatables jQuery plugin?

jrdavidson's avatar
jrdavidson's avatar Snapey5yrs agoForge
5
1
Last reply by Snapey 5yrs ago
NetoPVH's avatar

Pagination with AJAX

Hello everyone , I have a question and would greatly appreciate it if someone could help me . I need to make a paging with ajax . I found content on the internet , but to Laravel and 5.0 and could not apply in Laravel 5.2 that is my project . https://gist.github.com/tobysteward/6163902 Could someone explain me or send a link to how I could proceed. Thanks

NetoPVH's avatar
NetoPVH's avatar anlrommel1...6yrs agoLaravel
4
1
Last reply by anlrommel123 6yrs ago
Frosty's avatar

Unable to display one database item per page without pagination

Hello all, I am working on a project in order to get a better handle of Laravel 5.2 . The project is a simple app which takes a quote from the SQL database and displays it to the user. The user has an input field where he inputs his answer. If the user's input matches the author name, he gets a notification and his score increments by one, and the the next question is displaye

Frosty's avatar
Frosty's avatar Frosty10yrs agoLaravel
0
1
luddinus's avatar

Order by random with pagination

Hi. I would like to show some photos in a random order. The thing is that I would like to paginate those photos and not to repeat the ones which have been appeared. One option is this (thx to @rodrigo.pera) : "persisting or caching this random order, and maybe once a day rebuilding it. The rebuilding step can be done by scheduling a custom artisan command." What other

luddinus's avatar
luddinus's avatar jlrdw10yrs agoGeneral
1
1
Last reply by jlrdw 10yrs ago
Rjs37's avatar

Unusual Pagination Caching Problem

I'm getting a weird caching problem due to the way the paginator seems to generate the urls before it is even rendered. In my project I'm using a custom private package that is included for both our public and admin websites (they live as two separate laravel apps on the same server). I'm using repositories with caching wrapped around for example: // Eloquent Repository public

Rjs37's avatar
Rjs37's avatar Rjs3710yrs agoLaravel
1
1
Last reply by Rjs37 10yrs ago
stamatis's avatar

Products edit page with pagination for image select from Model Image

Greetings to all, I am really confused beacause after a lot of hours reading,searching, practising ("new to Laravel and not only"), I cannot find a way to (luck of knowledge) do the following: When i edit a product (url.1 products/1/edit) i included a blade view that shows all images from the model images with paginator and it works. But when i click on the paginato

stamatis's avatar
stamatis's avatar Mariam10yrs agoLaravel
5
1
Last reply by Mariam 10yrs ago
Moted's avatar

Laravel 5.x Pagination and recursive child categories.

Hey everyone, So I managed to finish my infinite nested categories. It was kind of simple and difficult at same time. I’m not really good with recursions. The reason of this post, if there is some way to optimize this code a little bit more. So my controller looks like this: public function index() { $categories = Category::all(); $categoriesPaged = $this->buildArray

Moted's avatar
Moted's avatar Moted10yrs agoCode Review
4
1
Last reply by Moted 10yrs ago
Learner's avatar

pagination problem

I tried to paginate but its renders class error. Where I am already added it use Illuminate\Pagination\Paginator; ' ' ' $rsSTDs = $this->ResultWithSTDsRegid($input, $rc)->paginate(5); private function ResultWithSTDsRegid($input, $rc) { $rc = $rc->where('Regid', CompleteRegid($input['Regid'])) ->where('ExamYear', $input[

Learner's avatar
Learner's avatar Learner10yrs agoLaravel
2
1
Last reply by Learner 10yrs ago
shez1983's avatar

Pagination, adding custom (array) parameters to render() using appends()

so I have a search form where I allow users to enter multiple items of same kind which results in an array.. so when i press submit it is sent as: param[]=2&param[]=4 etc.. but I am not sure how to add these to the paginator? {!! $jobs->appends(...)->render() !!} I was manually trying to create this but not sure how to? I can do a loop on param foreach ( $param a

shez1983's avatar
shez1983's avatar shez198310yrs agoLaravel
0
1
hussein4's avatar

Pagination render() error

i am trying a simplePaginate in L 5.1 but receive error ErrorException in Builder.php line 2071: Call to undefined method Illuminate\Database\Query\Builder::render() in my POController public function index() { $po =PO::orderBy('created_at', 'desc')->simplePaginate(10); return view ('pos.index', compact('po' )); } in my pos/index.blade.php @foreach

hussein4's avatar
hussein4's avatar hussein410yrs agoGeneral
2
1
Last reply by hussein4 10yrs ago
ayekoto's avatar

how I will use pagination for this scenario

$user = User::with('courses')->where('id', 1)->first(); Now in my view I did: @foreach($user->courses as $course) {{$course->name}} //display other columns @endforeach but the challenge is I have more than 40 courses, each user can offer, which just display all on the page, I was wondering if I can paginate the courses collection... And how will I go about it if

ayekoto's avatar
ayekoto's avatar ayekoto10yrs agoEloquent
2
1
Last reply by ayekoto 10yrs ago
joedawson's avatar

Pagination Issue

Hello all, I currently have an API endpoint that returns a paginated list of products. When my Vue component is ready, it makes a call to my endpoint and stores the the data in an array. Here's an example of my response from the products endpoint: { "data": [ { "id": 1, "name": "Willard Treutel",

joedawson's avatar
joedawson's avatar JoeDawson10yrs agoVue
2
1
Last reply by JoeDawson 10yrs ago
rene's avatar

Pagination with &sort in url?

Hi, I have in my code: public function index() { return User::paginate(20); } I kinda remember something likewise from L4, which also accepted sort= as parameter in the request, but that's not working? Now I can do: /users?page=10 to get page 10, but I also wanna sort my things with a URL like /users?page=10&sort=email&direction=desc Isn't that possible anymore wit

rene's avatar
rene's avatar Prullenbak10yrs agoLaravel
5
2
Last reply by Prullenbak 10yrs ago
Khudadad's avatar

Eloquent pagination

How do I paginate the result of this Eloquent public function show($slug) { $post = Post::where('slug',$slug)->with(['user','comment'])->first(); return view('discuss.posts.show',compact('post')); } When the comments about the specfied post is getting more than 10 should be paginated. Thanks

Khudadad's avatar
Khudadad's avatar RachidLaas...10yrs agoEloquent
7
1
Last reply by RachidLaasri 10yrs ago
bertug.personal@gmail.com's avatar

L5 Pagination + Infinite Scroll jQuery

I am trying to use paginate() to achieve infinite scroll. I think the easiest way is using the infinite-scroll to achieve this. If you have any other suggestion how to do it without infinite-scroll library, just using jQuery, I'd be happy to know.. I am returning the variable to view like: public function index() { $posts = Post::with('status' == 'verified')

bertug.personal@gmail.com's avatar
bertug.personal@gmail.com's avatar bertug.per...10yrs agoLaravel
0
1
FutureWeb's avatar

cached ajax Pagination with orderby and where

is it possible to manipulate a cached paginated collection with relationships? for instance: if(isset($_GET['page']) { $page=$_GET['page']; } else{ $page = 0; } $product = Cache::remember('product'.$page,7200,function() use($brand){ return Product::with('specs','pr

FutureWeb's avatar
FutureWeb's avatar FutureWeb10yrs agoEloquent
0
1

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.