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

angelsky's avatar

Pagination from merge()

Hello, I've merges 2 Collections: use Illuminate\Pagination\LengthAwarePaginator as Paginator; ... $towni18n = TownI18n::where(...)->get(); $town = Town::where(...)->get(); $all = $towni18n->merge($town); $perPage = 10; $input = \Input::all(); if (isset($input['page']) && !empty($input['page'])) { $currentPage = $input['page']; } else { $currentPage = 1; }

angelsky's avatar
angelsky's avatar angelsky10yrs agoLaravel
1
1
Last reply by angelsky 10yrs ago
cbaykam's avatar

Landish Pagination Limit number of pages.

How can I limit the number of pages to display in Landish/Pagination using the LengthAwarePagination Could not find any documentation. It always displays 10 pages.

cbaykam's avatar
cbaykam's avatar bflydesign9yrs agoLaravel
4
1
Last reply by bflydesign 9yrs ago
SergioGregorutti's avatar

REST API - Pagination best practice

Hi all, Im working on a REST API and I have a question. For example, I have an endpoint to get all categories: /api/categories Can I use the same endpoint to get all categories but paginated? Im thinking on something like: /api/categories?paginated=true But I dont know if there's a best practice to do this. What do you think? If someone has a suggestion will be great. Thanks in

SergioGregorutti's avatar
SergioGregorutti's avatar martinbean2yrs agoGeneral
6
1
Last reply by martinbean 2yrs ago
mardev's avatar

Route and pagination problems

Hi guys! I have som URL problems. Whenever I try to link to a route thats not in the route file I'm redirected back to '/'. I'm trying to paginate my result and when I press the next button or type in localhost:8888/result?page=2 it just redirects me. Any ideas?

mardev's avatar
mardev's avatar milroy10yrs agoLaravel
4
1
Last reply by milroy 10yrs ago
silverstone12's avatar

Using query strings and pagination

I'm trying to create a page that displays products from my database. It contains a search bar at the top, and then just lists products underneath. Here is the code from my controller: public function index(Request $request) { $query = $request->input('search'); if ($query) { $comics = Comic::where('name', 'LIKE', "%$query%")->paginate(8);

silverstone12's avatar
silverstone12's avatar neovive10yrs agoCode Review
3
1
Last reply by neovive 10yrs ago
kfirba's avatar

Caching pagination with repository

Hello! I have some repositories for my models and I would like to add a cache decorator to some of them. The only issue is that I have a method paginate() which I don't know how to cache: public function paginate($perPage = 15, $columns = ['*']) { return $this->model->paginate($perPage, $columns); } How can I cache it efficiently and make it aware to the

kfirba's avatar
kfirba's avatar kfirba10yrs agoGeneral
8
1
Last reply by kfirba 10yrs ago
londoh's avatar

mobile pagination and post date

I'm mostly using a phone to view the forums atm, here's a couple things i think would help @JeffreyWay please consider: put page links at the top and bottom. Its a pain clicking thru to a multi page thread and scolling all the way down to page on put the post date in the header. Its important context and the user avatar makes the block pretty tall so theres enough space to

londoh's avatar
londoh's avatar londoh10yrs agoFeedback
0
1
reny410's avatar

Manual pagination after sorting won't render

I have this code $lessons = Lesson::approved()->get(); $lessons = $lessons->sortBy(function($lesson){ return $lesson->getViewCount(); }); $lessons = $lessons->reverse(); $lessons = new Paginator($lessons, 3); $lessons->setPath('sort'); $lessons->appends(['sort' => 'viewdesc']); is there something wrong with my code? I couldn't use simplePaginate becaus

reny410's avatar
reny410's avatar reny41010yrs agoEloquent
0
1
strategicsdemexico's avatar

Pagination and Vue.js

I'm doing ajax request to get all Events from my Event Model public function index(Request $request) { $events = $this->eventRepo->paginate(15); if( $request->ajax() ) return $events; return view('events.index', compact('events')); } This events collection has a collection of the event model (obviously but i have to mentioned), i have the relation this eve

strategicsdemexico's avatar
strategicsdemexico's avatar agprasha10yrs agoVue
3
1
Last reply by agprasha 10yrs ago
jrean's avatar

Pagination and Chunk

Hi, My controller returns a LengthAwarePaginator to my view. Within my view I: @foreach ($foos->chunk(3) as $foos) <div class="row"> @foreach ($foos as $foo) <article class="col-xs-12 col-md-4"> <div class="visible-xs-block">

jrean's avatar
jrean's avatar jrean10yrs agoEloquent
2
1
Last reply by jrean 10yrs ago
techykiddo's avatar

Infinite scroll pagination on Laravel 5

Hi. Can anybody help and suggest how to implement infinite scrolling of data entries in laravel 5? like, for example, you have 100 articles, then 10 is initially loaded and when the user is scrolling in down to the bottom, it loads another set of articles until all article is loaded? Thanks in advance

techykiddo's avatar
techykiddo's avatar RachidLaas...11yrs agoRequests
15
1
Last reply by RachidLaasri 11yrs ago
oneshoe's avatar

Bug: Pagination on /admin/history does not work

The viewing history pager is broken. I only ever see the first page. Open the sidebar and click "Viewing History". Result: I end up on /admin/history where I see the last 15 episodes I watched. Below that is a pager from 1 to 5, with 1 active. Click on 2 or >> on the pager bar. Result: I end up on /admin/history/?page=2 where I see the same last 15 episodes

oneshoe's avatar
oneshoe's avatar oneshoe11yrs agoFeedback
0
1
beniamino's avatar

[SOLVED] L5 pagination appends array

Hi folks, i would need to pass query string to my paginator pages links. I' have done that with this code {!! $items->appends(Request::query())->render() !!} It works very well with a simple key:value pair, but it wrong render arrays (like multiselects, checkboxes, etc.). I would expect something like that for a multiselect called "item": item[]=1&item[]=2.

beniamino's avatar
beniamino's avatar beniamino11yrs agoTips
1
1
Last reply by beniamino 11yrs ago
TomCawthorn's avatar

Pagination with Group By not working

I know from the docs that when paginating with a query that contains Group By isn't going to work. I'm struggling with the alternative, custom method. So the Paginator class is initialised with: <?php public function __construct($items, $perPage, $currentPage = null, array $options = []) I'm calling the object like this for now <?php return new \Illuminate\Paginatio

TomCawthorn's avatar
TomCawthorn's avatar TomCawthor...11yrs agoLaravel
1
1
Last reply by TomCawthorn 11yrs ago
fetch404's avatar

Collection pagination problem

I'm having a problem with paginating collections. I made a search function, and it gets all the results fine. But when I try to use the paginator... well, it shows the same stuff on every page. If someone could help, I would appreciate it. My search function: /** * Search in the database for certain items * * @param SearchRequest $request * @return mixed

fetch404's avatar
fetch404's avatar beznez11yrs agoLaravel
2
1
Last reply by beznez 11yrs ago
abhishek009's avatar

Pagination in L5

I have this code : $status = statuses::whereIn('uid', $following)->with('user')->latest()->paginate(5); In blade : {{ $status->render() }} Showing this error : Call to undefined method Illuminate\Database\Query\Builder::render() (View: C:\xampp3\htdocs\resources\views\home.blade.php)

abhishek009's avatar
abhishek009's avatar abhishek00...11yrs agoGeneral
11
2
Last reply by abhishek009 11yrs ago
luanrodriguesp's avatar

[L5] Pagination Model

Hello guys, Im trying to paginate a eloquent relation and im getting a lot of problems. This is my model...

luanrodriguesp's avatar
luanrodriguesp's avatar JarekTkacz...11yrs agoGeneral
4
1
Last reply by JarekTkaczyk 11yrs ago
Komayo's avatar

Pagination Help - Filters

Hello guys, I have a few paginations on a project and i want the user to select the total items to view for each page, like a filter. In the view with the paginator. How can i achieve this, whats the best way to do it? Thank you.

Komayo's avatar
Komayo's avatar RachidLaas...11yrs agoGeneral
1
1
Last reply by RachidLaasri 11yrs ago
moltar's avatar

Any idea how to solve pagination issue with having clause?

The issue described here: https://github.com/laravel/framework/issues/3105 Super stalling out Eat Sleep MVP project :(

moltar's avatar
moltar's avatar blueoctopu...7yrs agoGeneral
18
1
Last reply by blueoctopus 7yrs ago
tebowner's avatar

pagination on complex sql

I have a complex sql that produces a large array. $documents = DB::select( DB::raw($selectstatement), $binders); $pageNumber = \Request::get('page', 1); $perpage = \Request::get('perpage', 10); $slice = array_slice($documents, $perpage * ($pageNumber - 1), $perpage); $documents = \Paginator::make($slice, count($documents), $perpage); in Laravel 5 is this the best way to do this

tebowner's avatar
tebowner's avatar kimsyverse...10yrs agoGeneral
21
2
Last reply by kimsyversen 10yrs ago
Komayo's avatar

Pagination in view

How can i use the following paginator in the blade view? $paginator = new Paginator($render_data, count($render_data), 5); Iam passing the $render_data to view, and using it on a @foreach loop

Komayo's avatar
Komayo's avatar rodrigo.pe...11yrs agoGeneral
4
1
Last reply by rodrigo.pedra 11yrs ago
ruffsaint's avatar

dear friends, Please i av problem pagination

This is the code : {{ $user->links() }} but this is the error: Call to undefined method Illuminate\Database\Query\Builder::links() (View: C:\xampp\htdocs\authpro\resources\views\account\index.blade.php)

ruffsaint's avatar
ruffsaint's avatar ruffsaint11yrs agoGeneral
7
1
Last reply by ruffsaint 11yrs ago
Jinggo's avatar

Laravel 5 Pagination Error in Production

Hi, Anyone experienced this? It occurs in production... FatalErrorException in LengthAwarePaginator.php line 126: Access to undeclared static property: Illuminate\Pagination\LengthAwarePaginator::$presenterResolver working in homestead and localhost. Also, someone has the same issue from stackoverflow. http://stackoverflow.com/questions/29117020/laravel-5-render-pagination-err

Jinggo's avatar
Jinggo's avatar cluebatter...8yrs agoGeneral
8
1
Last reply by cluebattery 8yrs ago
opheliadesign's avatar

Find the pagination page where an item will be placed or exists

Hi everyone, I am making a forum very similar to this one (it's my inspiration). When a user posts a reply to a thread I'd like to direct them to the end of the list of paginated replies with their reply's anchor (same behavior as this forum). I'd also like to return the user to the correct page when they edit one of their replies. How can I figure out which page a new reply wi

opheliadesign's avatar
opheliadesign's avatar nexxai5yrs agoGeneral
6
1
Last reply by nexxai 5yrs ago
technogenes's avatar

Laravel 5 Pagination

Getting following error FatalErrorException in 73cec445eee8ed02451395c61bbdf2a4 line 52: Call to undefined method Illuminate\Database\Eloquent\Collection::render() in 73cec445eee8ed02451395c61bbdf2a4 line 52 at HandleExceptions->fatalExceptionFromError(array('type' => '1', 'message' => 'Call to undefined method Illuminate\Database\Eloquent\Collection::render()', 'file'

technogenes's avatar
technogenes's avatar usman11yrs agoGeneral
2
1
Last reply by usman 11yrs ago
jsherman95's avatar

Watch Later Pagination Problems

The button to go to the next page on my Watch Later list seems to be broken. The link points to https://laracasts.com/search/?page=2 and when I click on it I am sent to https://laracasts.com/discuss? So I can never see any more than my first page of lessons that I have marked as Watch Later. Thanks for the great service.

jsherman95's avatar
jsherman95's avatar mrliptonte...11yrs agoFeedback
1
1
Last reply by mrliptontea 11yrs ago
cyberomin's avatar

Eagerloading relations with pagination

Hi, I am working on a Forum system. I have my comments and post thread eager loaded. I want to paginate the comments results and render it on a page. I am using L5. /** * The author of a post * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function author() { return $this->belongsTo('Community\User', 'user_id'); }

cyberomin's avatar
cyberomin's avatar JarekTkacz...11yrs agoGeneral
9
1
Last reply by JarekTkaczyk 11yrs ago
chrislentz's avatar

How can you adjust the Pagination classes in #L5?

In Laravel 5, Custom Presenters have been removed? Does anyone know what the alternative is in Laravel 5 to adjust the class names and view data? http://laravel.com/docs/4.2/pagination#custom-presenters I am trying to match the classes to for Foundation 5 instead of Bootstrap.

chrislentz's avatar
chrislentz's avatar chrislentz11yrs agoGeneral
1
1
Last reply by chrislentz 11yrs ago
gretschduojet's avatar

Eager Loading with Pagination

Hello, I have a user profile and a user can have many products. I am currently eager loading the users products and I'm able to display the products on the users profile. However, I would like to be able to paginate the products if the user has more than 5 products. What would be the best way to do that? Thank you in advance for the help.

gretschduojet's avatar
gretschduojet's avatar JarekTkacz...11yrs agoGeneral
11
1
Last reply by JarekTkaczyk 11yrs ago
bashy's avatar

Pagination bug on "My Threads"

https://laracasts.com/discuss?filter_by=contributed_to Can't go to second page. It links to /search/?filter_by=etcetc

bashy's avatar
bashy's avatar JeffreyWay11yrs agoFeedback
2
1
Last reply by JeffreyWay 11yrs ago
robindboer's avatar

Pagination with a custom starting point

Hey Everyone, Im building a RESTful webservice and when a user requests a collection I want them to be able to specify a limit and a starting point as URL-params. Currently i'm calling paginate on my Eloquent model and giving the limit as an argument. However I cant find a way to let users specify a starting point as URL-param. I hope everything is clear, and someone has a s

robindboer's avatar
robindboer's avatar robindboer11yrs agoGeneral
4
1
Last reply by robindboer 11yrs ago
radioheart's avatar

Laravel Pagination Problem

i'm getting error when i add paginate how can i fix it? array_key_exists(): The first argument should be either a string or an integer $titles = Titles::join('users', 'entries.user_id', '=', 'users.id') ->where(function($query) use ($value,$uni_id) { $query->whereIn('entries.user_id', function($query) use ($value) { $qu

radioheart's avatar
radioheart's avatar radioheart11yrs agoGeneral
1
1
Last reply by radioheart 11yrs ago
leonan's avatar

Pagination Issue

Hello, In an attempt to display the most recent activity updates by some users I am querying the database to grab only 20 updates and to paginate them at 5 per page. But the query below grabs and displays all logged activities (35) at 5 per page, which I only want 20. Using ->paginate $paginator = DB::table('activity_log') ->leftJoin('assigned_agents',

leonan's avatar
leonan's avatar leonan11yrs agoRequests
0
1
chrisgeary92's avatar

Eager Loading Polymorphic Relations w/ Pagination

Hi Guys, Does anyone know if it's possible to eager load a polymorphic relationship that's being paginated? I can't seem to get it to work, if I paginate by 25 records, it's running a query for each. I think I read online somewhere (a while ago) that this wasn't possible, but I can't remember where I saw this, and to be honest I may be imagining it. This is what I'm currently

chrisgeary92's avatar
chrisgeary92's avatar bestmomo11yrs agoGeneral
1
1
Last reply by bestmomo 11yrs ago
p4bloch's avatar

[L4-BUG?] Pagination layout breaks on production but works fine in local

I get a nice formatted ul for Bootstrap 3 on Homestead, but in the production website the markup is different, therefore breaking the layout. I'm running locally with Homestead and on production with Forge. I'm not using a local view.php configuration file that would overwrite any functionality. I do am using a custom paginator for one page, but it doesn't make sense that it

p4bloch's avatar
p4bloch's avatar p4bloch11yrs agoGeneral
1
1
Last reply by p4bloch 11yrs ago
macmotp's avatar

L5 creating API with pagination - Issue

I am trying to create an API with Laravel 5 and in order to refresh my memory for a good architecture I followed again the "Incremental APIs" series. Everything worked perfectly until I tried to paginate my results, this is the error I have (I duplicate my code for help using the same situation as Jeffrey did so you will find 'Lessons' and 'title'): ErrorException in LessonTra

macmotp's avatar
macmotp's avatar macmotp10yrs agoGeneral
4
1
Last reply by macmotp 10yrs ago
tios's avatar

[L5] Pagination links

Using {!! $items->links() !!} in a fresh 5.0 installation I get the following error: UndefinedMethodException in ... Attempted to call method "links" on class "Illuminate\Pagination\Paginator" What happened to this feature? Must I load a package?

tios's avatar
tios's avatar tios11yrs agoGeneral
2
1
Last reply by tios 11yrs ago
sonali1908's avatar

Pagination and Eager Loading

My Controller method is: $topics=Topic::with(array('subtopics'=>function($query){ $query->with('resources')->orderBy('glc_subtopic_priority','asc')->paginate(1); }))->find($id); return View::make('subtopics.index')->with('topics', $topics); I am eager loading this and it works fine. But now I want to paginate this. The problem is when I am displayi

sonali1908's avatar
sonali1908's avatar sonali190811yrs agoGeneral
0
1
jalaf11201's avatar

I'm having problems on deciding an architecture for sub navs, and I'm having trouble on deciding how to manage the page without refresh without messy code.

I'm creating a community based SN, I created manage section for community owners, and there is nav on top like general, privacy, sections (flairs), users (follow, requests), posts (requests, pinned, etc.) inside. I created blade pages for them, but inside them there are sections again. Like Followed, Requests, Pinned, Removed etc. Making separate pages for them would be bad. I

jalaf11201's avatar
jalaf11201's avatar vincent150...4w agoGeneral
1
3
Last reply by vincent15000 4w ago
tarcisiodev1's avatar

Laravel Tailwind tables (like Yajra, no Livewire)

Good evening, everyone! I’m looking for recommendations for libraries or packages to create tables in Laravel using Tailwind CSS. Previously, I used Yajra Laravel DataTables with Bootstrap, but now I want to switch to a solution that works well with Tailwind and, preferably, doesn’t rely on Livewire. Does anyone have suggestions for packages or approaches that can replace Yajra

tarcisiodev1's avatar
tarcisiodev1's avatar jlrdw2mos agoLaravel
1
1
Last reply by jlrdw 2mos ago
yonka's avatar

Read All TakenInventoryInfo and Paginate it

I want to read TakenInventoryInfo and Paginate all by also reading StoreFrom from TakenInventories. This is my database design 1.TakenInventoryInfo class TakenInventoryInfo extends Model { use HasFactory, CreatedUpdatedBy, softDeletes; protected $fillable = ['tracking_no','taken_date','store_id','reference','description','approve_status','user_id']; public functio

yonka's avatar
yonka's avatar LaryAI3mos agoLaravel
1
1
Last reply by LaryAI 3mos ago
kajol's avatar

How I Structure Laravel APIs for Android Apps (Versioning, Auth, Queues, Performance & Multi-Tenant Setup)

Over the past few years I’ve been building Android apps paired with Laravel backends, and I kept running into the same problems: breaking older app versions because I changed an API inconsistent response formats heavy logic inside controllers causing UI delays background tasks slowing down mobile requests auth flows that worked in Postman but failed on real devices rate limiti

kajol's avatar
kajol's avatar jlrdw6mos agoDevOps
2
2
Last reply by jlrdw 6mos ago
vincent15000's avatar

Splide with a rolling window of 21 items

Hello, It's a project with Laravel and VueJS. I'm using Splide to display a carousel. To avoid to have too many requests, I'd like to load a window around the central item displayed on the screen. For example if I display the first item among 33, I want to display item 1 and also load the 10 previous and 10 next items. As it's the first one to display, I will load the items fro

vincent15000's avatar
vincent15000's avatar vincent150...6mos agoGeneral
0
1
ctrlaltdelme's avatar

Infinite Scrolling

I'm trying to implement infinite scroll per Jeffrey's video and I don't have it quite right. I am paginating my Tag model and returning some other metadata to the page. public function index() { $tags = Tag::query() ->withCount('posts') ->orderBy('posts_count', 'desc') ->orderBy('name') ->paginate(15);

ctrlaltdelme's avatar
ctrlaltdelme's avatar ctrlaltdel...9mos agoInertia
3
1
Last reply by ctrlaltdelme 9mos ago
aalaap's avatar

Large CSS and JS bundle size out of the box on Laravel 12 and no starter kit

On a fresh Laravel 12 project, I noticed that the bundled CSS was a rather large ~33kb and JS was ~35kb. I was using no Tailwind CSS classes in my "hello world" Blade view and no JavaScript either, so this was strange. I took a few steps to bring down the CSS: Removed the default Tailwind CSS definition under the @if-@else block, where it includes the built CSS/JS if

aalaap's avatar
aalaap's avatar JussiManni...10mos agoVite
2
12
Last reply by JussiMannisto 10mos ago
minaremonshaker's avatar

how can i make filter , search , sort functionality in blade , i am not using api

I want to implement search functionality along with sorting (orderBy) and pagination (per page). However, I'm having trouble customizing the query string in my Blade form to support all of these features. For example, I am using the Spatie Laravel Query Builder package, which expects URLs in this format: GET /users?filter[name]=john&filter[email]=gmail How can I customize m

minaremonshaker's avatar
minaremonshaker's avatar minaremons...10mos agoGeneral
7
3
Last reply by minaremonshaker 10mos ago
Shivamyadav's avatar

Infinite scroll on search not working?

I'm using laravel with inertia and vue . Infinite scroll on load when visible is working and the first search with infinite is also wroking. What's the problem When i again try to override that search input then the scroll is not working in the network tab also i can not see any hitting url. Help me :( my script <script setup> import { Link, router, usePage, WhenVisible

Shivamyadav's avatar
Shivamyadav's avatar Shivamyada...10mos agoLaravel
1
2
Shivamyadav's avatar

Load more does not show up after first time even in throttling from network tab?

Trying to implement the infinite scroll and it working but the loading more text does not pop up to show the user as a feedback that data is loading. My when visible component that inertia provides. <WhenVisible :always="!reachedEnd" :params="{ data: { page: usePage().props.pagination.current_page +

Shivamyadav's avatar
Shivamyadav's avatar Shivamyada...10mos agoVue
0
1
kanak09's avatar

Keep state while lazy loading tabs data

Hello, I am struggling doing something simple using Inertia. I have a page presenting an online Course with a sticky sidebar showing Course details and tabs with specific course data like : main content, chapters, faq, reviews... The data are simply rendered using Inertia::render('courses/CourseDetail', ...) and it works. Now I would like to optimize the speed and UX, so natura

kanak09's avatar
kanak09's avatar kanak0910mos agoInertia
3
1
Last reply by kanak09 10mos ago
salioudiabate's avatar

How to calculate the total of all filtered rows, not just the current page rows in footer() with Rappasoft laravel-livewire-tables

Package : Rappasoft laravel-livewire-tables Hi, I'm using the footer() method on a column to display the sum of a numeric field (e.g., amount). I noticed that the $rows parameter passed to the footer callback only contains the rows visible on the current paginated page. Example: Column::make('Amount') ->footer(fn($rows) => 'Subtotal: ' . $rows->sum('amount')) This

salioudiabate's avatar
salioudiabate's avatar salioudiab...1yr agoLivewire
1
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.