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

Aishan's avatar

pagination in laravel 8 goes to the top of the page

I have added pagination method on of the table result in the blade, but I placed the table below the page and every time I click on the next page it takes me to the top of the page which is really annoying scrolling down to the page every time I click on the specific page. Does anybody have a solution to stay right where we first clicked on the page? {{ $search_result->with

Aishan's avatar
Aishan's avatar Snapey3yrs agoLaravel
8
1
Last reply by Snapey 3yrs ago
abbasrahim723's avatar

Single Page Pagination

Hello Everyone! I am using pagination in my project on the posts page, which works fine, but I want to have pagination on a single post page, where I can go back and forth for another single post. I already have pagination links on a single post page, but on clicking next it just refreshes and stays on the same post, however, the page number changes in the URL. Thanks

abbasrahim723's avatar
abbasrahim723's avatar abbasrahim...3yrs agoCode Review
8
1
Last reply by abbasrahim723 3yrs ago
Aishan's avatar

pagination in laravel 8

I do not know where to put pagination method in the below query, I have tried to replace it with get() but it gives me error. Can anyone help me please? $search_result= Project::join('project__reports','projects.id','=','project__reports.project_id') ->select(array('projects.*', 'project__reports.status', 'project__reports.notes','project__reports.p

Aishan's avatar
Aishan's avatar Aishan4yrs agoLaravel
3
1
Last reply by Aishan 4yrs ago
norsecomics's avatar

Wire:init issue with pagination

I am trying to render a table with pagination, and to pull in a required image I am using a wire:init to load the image, however, without the wire:init the pagination works flawlessly, but with wire:init pagination is failing. I am unsure why this would be, but would welcome any help Here's the livewire that is being pulled in through @livewire @if($isLoading) <s

norsecomics's avatar
norsecomics's avatar norsecomic...4yrs agoLivewire
4
1
Last reply by norsecomics 4yrs ago
usman31's avatar

server side pagination

I want to implement server side pagination with simple jQuery and Laravel on ag-grid but I can't find any related example or guide. can anyone help me?? link for the js https://www.ag-grid.com/

usman31's avatar
usman31's avatar Braunson4yrs agoLaravel
1
1
Last reply by Braunson 4yrs ago
nebulous0's avatar

search query get request from form with pagination

so i have a form that sends a post request to a controller with the search query entered, this returns a paginated list of games that match the query, except since its a post request pagination wont work. so i changed the form to send the query as a get request i changed the route and controller but it only made a 404 not found error and didnt even get to the controller, id lik

nebulous0's avatar
nebulous0's avatar tykus4yrs agoLaravel
1
1
Last reply by tykus 4yrs ago
lara28580's avatar

Livewire pagination exception

I have a problem with the livewire pagination it always throws an error if I am going back to the first page. Following exception is thrown Uncaught TypeError: Cannot read properties of null (reading 'match') at Directive.value (wire-directives.js:86:45) at Directive.get (wire-directives.js:58:33) at node_initializer.js:209:42 at Component.value (index.js:582:9)

lara28580's avatar
lara28580's avatar SmokeTM4yrs agoLivewire
4
1
Last reply by SmokeTM 4yrs ago
franvillada's avatar

Collection Pagination with Laravel + Inertia (React)

Hi everyone! I'm having some issues implementing pagination for a collection. So this is my relevant code: My controller method: public function create(): Response { // Primero obtengo el plan de cuentas $response = HTTP::get('http://localhost:8001/api/cuentas'); $plan_de_cuentas = collect($response->json()); // Después tengo que filtrar

franvillada's avatar
franvillada's avatar Glukinho9mos agoInertia
5
1
Last reply by Glukinho 9mos ago
knubbe's avatar

Nuxt 3 pagination with Laravel API

I am trying to implement basic pagination in Nuxt 3 app but I can't solve reactivity on next and previous button. What can be the best possible way to implement that functionality? This is what I have: <script setup> import { UserCircleIcon, ArrowNarrowLeftIcon, ArrowNarrowRightIcon } from "@heroicons/vue/solid"; import { ref } from "vue"; const page

knubbe's avatar
knubbe's avatar knubbe4yrs agoVue
0
1
VertexBuffer's avatar

Eloquent GroupBy Pagination?

I'm dealing with an app that has some data I need to sort into groups based on the day they were created, and then be paginated for view on a webpage. I've gotten the basics working; $result = Model::query()->oldest()->get()->groupBy(function ($model) { return $model->created_at->format('j-M-Y'); }); I've scowered the web for an answer to this, and every

VertexBuffer's avatar
VertexBuffer's avatar jlrdw4yrs agoCode Review
3
1
Last reply by jlrdw 4yrs ago
shimana's avatar

pagination in a query

I want to filter the display of images with this query. And it works for me but the problem is with the pagination. I use Load More On Page Scroll. When I display images in a category and click load more, more images are displayed. But when I go to another category, like the previous category, more images are displayed without me clicking on load more. I want more images to be

shimana's avatar
shimana's avatar undeported...4yrs agoLaravel
5
1
Last reply by undeportedmexican 4yrs ago
Aishan's avatar

Laravel 8 issue with pagination and unique method

Can anyone help me with this? Pagination doesn’t work with Unique() method and I tried it with distinction but the output is not unique ! $search_result= Project::join( 'project__reports' ,'projects.id','=', 'project__reports.project_id' ) ->select(array('projects.*', 'project__reports.status' ,'project__reports.notes', 'project__reports.prgs_prc' ,'project

Aishan's avatar
Aishan's avatar Aishan4yrs agoLaravel
26
1
Last reply by Aishan 4yrs ago
mahbubrn's avatar

In pagination laravel not showing number

I'm stuck with a problem in my laravel 9 web app. Pagination number not showing in the blade file. Only display the "Pagination.Previous" "Pagination.Next" link. My code is In Controller: $list = District::active()->orderBy('name')->paginate(10); return view('district.list', compact('list')); In view: @if ($list->hasPages()) {{ $list->links() }}

mahbubrn's avatar
mahbubrn's avatar jlrdw4yrs agoLaravel
9
1
Last reply by jlrdw 4yrs ago
jaeyson's avatar

inserting some data in a pagination

Hi! is it possible to add data in pagination without using LengthAwarePaginator? data is an array of strings and i'd add it randomly per page

jaeyson's avatar
jaeyson's avatar tykus4yrs agoLaravel
9
1
Last reply by tykus 4yrs ago
edres's avatar

show max 5 link of pagination in every page

i need max 5 link of pagination in every page. so if i have 10 page and when i click on link page 5 in the pagination next show me links 2 to 6 in the bottom of site

edres's avatar
edres's avatar edres4yrs agoLaravel
4
1
Last reply by edres 4yrs ago
kikter's avatar

laravel pagination not displaying correctly

I was working on listing my post so after the foreach I tried to get the pagination link and the links are been displayed like this pagination.previous. & pagination.next

kikter's avatar
kikter's avatar Nakov4yrs agoLaravel
4
1
Last reply by Nakov 4yrs ago
flynnmj's avatar

Pagination issues with large data set.

Laravel 8.x Postgres 12.x I have an API call with pagination that lets get the status of all their requests. Recently a customer reported an issue with getting all of their results. Inside the controller method is a simple Eloquent query that uses pagination to return the results. $clientRequests = Request::with(['content', 'user', 'client']) ->when($request->

flynnmj's avatar
flynnmj's avatar flynnmj4yrs agoEloquent
3
1
Last reply by flynnmj 4yrs ago
milar's avatar

laravel pagination links not working

I was using a bootstrap 5 template within my Laravel project. Now in the data table, I have created pagination links that appear really weird and it seems nothing can fix them. What can be done in this case? Controller public function index() { $categories = Category::query(); if($keyword = request('search')) { $categories->where('title' , 'LIKE' , "%{$k

milar's avatar
milar's avatar kar4yrs agoLaravel
5
1
Last reply by kar 4yrs ago
idcreatv's avatar

Weird issue - pagination returning incorrect record when spanning pages

Hey folks, I appear to have a very weird bug and I can't understand why its happening. Basically, I have the most simple controller index view which returns bookings which have a status of 1 (active) and then orderby start_date descending and paginate into 'batches' of 20… $bookings = Booking::where('status', 1) ->orderby('start_date', 'desc') ->with(['c

idcreatv's avatar
idcreatv's avatar Sinnbeck4yrs agoCode Review
3
1
Last reply by Sinnbeck 4yrs ago
mstdmstd's avatar

Why can't I set custom pagination in AdminLTE / laravel 9 app?

Working with AdminLTE(3.2.0) in laravel 9 I want to make custom pagination and I run command : php artisan vendor:publish --tag=laravel-pagination and in file app/Providers/AppServiceProvider.php I added line : public function boot() { JetstrapFacade::useAdminLte3(); // \Illuminate\Pagination\Paginator::useBootstrap(); // If to uncomment this line it do

mstdmstd's avatar
mstdmstd's avatar YeZawHein4yrs agoLaravel
1
1
Last reply by YeZawHein 4yrs ago
syofyanzuhad's avatar

Laravel Pagination Numbering API

How can i return the item number of the resource in API with pagination? i use the paginate() function as usual my json now is like this: { "success": true, "status": "success", "message": "Karyawan berhasil ditampilkan", "data": { "current_page": 1, "data": [

syofyanzuhad's avatar
syofyanzuhad's avatar syofyanzuh...4yrs agoLaravel
0
1
AndyMillne's avatar

tailwind pagination classes not compiled

I came across a bit of a challenging issue that took me a long time to work out. "npm run dev" does not include classes required for the pagination items when called via the links() helper method. For now I've added an empty div on the page with the missing classes to get them to compile e.g. <div class="sm:hidden hidden sm:flex-1 sm:flex sm:items-center sm:ju

AndyMillne's avatar
AndyMillne's avatar Nakov4yrs agoDesign
3
1
Last reply by Nakov 4yrs ago
MooseSaid's avatar

How to exclude certain styling in page2 in pagination

Hi, I have followed Jeffery Way in Laravel 8 from scratch amazing series but I'm having a trouble in pagination. In the index page we're making our latest post to have a specific styling and then first 2 posts comes after with a different styling and then rest of posts in different styling. The problem is that these styles are carrying over with us to page2 and 3 and ...etc I w

MooseSaid's avatar
MooseSaid's avatar MooseSaid4yrs agoLaravel
1
1
Last reply by MooseSaid 4yrs ago
enzer's avatar

How Change Pagination Number Mode to Load More Button

Hello i want change Pagination Number mode to Load more button. Please Help me change this This is my Controller.php public function index() { //$Topmusics = Post::orderBy('download_count', 'DESC')->paginate(13); $FeaturedMusics = Post::orderBy('id','desc')->paginate(30); return view('Pages.Music.index',compact('FeaturedMusics')); } /** * Display the specified resource.

enzer's avatar
enzer's avatar Yarad4yrs agoDesign
1
1
Last reply by Yarad 4yrs ago
suka's avatar

Laravel search with pagination and resource collection

How can I search a model and perform where clause of the collection without limiting to the pagination return [ 'data' => $this->collection, 'all' => $this->total(), 'tcases' => $this->whereIn('c_t', [1,2,3,4,5,6,7,8,9,10,11])->count(), 'tsc' => $this->where('c_t', 1)->count(), 'tca' => $this->where('c_t', 2)->count(), 'thc' => $this-&g

suka's avatar
suka's avatar suka4yrs agoLaravel
0
1
lat4732's avatar

AJAX results pagination problem

Hey, @everyone! I'm paginating my results which are displayed through AJAX request but I'm facing a problem with the pagination. Here's my pagination logic: function showReviews(page = 1) { return $.get(searchUrl(page)).done(function (reviews) { // .... }); }); if(reviews.pagination.next_page_url != null || reviews.pagination.current_page != 1) { var pa

lat4732's avatar
lat4732's avatar jlrdw4yrs agoLaravel
8
1
Last reply by jlrdw 4yrs ago
stefancoding's avatar

Page pagination with numbers

Hi all, I try to get page pagination with numbers but all what showing me is only Next and Previews button. $products = Product::whereIn('id', $productId) ->where('status', '=', 'Live') ->orderBy('quantity', 'desc') ->paginate(10); in my blade file I added this code {{ $products->links() }}

stefancoding's avatar
stefancoding's avatar abolfazlah...4yrs agoLaravel
8
1
Last reply by abolfazlahmadiweb 4yrs ago
k0tkin's avatar

Get data from two models as one variable with pagination

I'm working on a social media app, users have Post.php and PostComment.php models I want to show user's posts AND comments in their profile at the same time with pagination and sort them by created_at somehow merging the results from two models but with pagination So if pagination is on 10 and the user had 10 comments recently we will get only 10 comments and no post I don't wa

k0tkin's avatar
k0tkin's avatar rodrigo.pe...4yrs agoEloquent
5
1
Last reply by rodrigo.pedra 4yrs ago
1chbinamin's avatar

Pagination with Meilisearch shows more results after clicking on last link.

Meilisearch and the whole webapp itself work. But when I click on a last item number on the pagination element, it shows me more pagination links plus more total results based on the search query than it actually is. For example: I use "qui minima" as query param for Meilisearch to return the results. The page renders 4 pagination links and it also says "Showing

1chbinamin's avatar
1chbinamin's avatar 1chbinamin3yrs agoLaravel
2
2
Last reply by 1chbinamin 3yrs ago
Simone94's avatar

Pagination in Laravel

Hi, I need to do a pagination of some data I get from a DB. Since it's a lot of data, I wanted to do a pagination in one view. How can I do this? At the moment I have only created a pagination with 10 elements with: $data=DataFromRasp::simplePaginate(10); My controller is this: class DeviceController extends Controller { public function index() { $data=Device::all();

Simone94's avatar
Simone94's avatar PhumeleleS...4yrs agoLaravel
8
1
Last reply by PhumeleleSJose 4yrs ago
MahmudLaravel's avatar

Laravel shows two pagination

Hello I am new in Laravel. Sorry if my question is not match with the quality of this forum. I add $collection->links() in the blade. Now it shows two pagination. Any solution how to fix that? Thank you in advanced.

MahmudLaravel's avatar
MahmudLaravel's avatar MahmudLara...4yrs agoLaravel
7
1
Last reply by MahmudLaravel 4yrs ago
vainway 's avatar

pagination is affecting my foreach records

when I use pagination I lose the other records that are being retrieved from the database ex: on the first page I can see all the records but when I go on the next http://127.0.0.1:8000/irrigation?page=2 the records get lost. app.blade.php these records below are the ones that are getting lost <div class="col-lg-3"> <div class="widget"&g

vainway 's avatar
vainway 's avatar MichalOrav...4yrs agoLaravel
9
1
Last reply by MichalOravec 4yrs ago
jawi289p's avatar

Using Pagination with Query Builder

Hello, I want to add pagination for all the products on the products page. I have tried to add it but getting error. Please anyone can help me? Here is the image of the code: https://ibb.co/mNDJXyj

jawi289p's avatar
jawi289p's avatar jawi289p4yrs agoLaravel
6
1
Last reply by jawi289p 4yrs ago
_christoph's avatar

Customizing pagination for Inertia (React)

Ok, so the docs are pretty clear on this topic (for the most part) https://laravel.com/docs/8.x/pagination#customizing-the-pagination-view So the examples given there (above the artisan vendor:publish command, which I ran), appears to be code that you would include in your blade component. That's all well and good except that with Inertia (I'm using react), you can't really pu

_christoph's avatar
_christoph's avatar _christoph4yrs agoLaravel
2
1
Last reply by _christoph 4yrs ago
Vinciepincie's avatar

checkbox filter does not work with pagination. GET method not supported.

Hello. there's a checkbox, when clicked only finished transactions will show. This works fine without pagination. When i add pagination it shows "The GET method is not supported for this route. Supported methods: POST." when i click the checkbox and go to another page. Livewire class: class TransactionListPrivate extends Component { public $receiveActiveOnly = tr

Vinciepincie's avatar
Vinciepincie's avatar Nakov4yrs agoLivewire
1
1
Last reply by Nakov 4yrs ago
ilex01's avatar

Remove previous button on laravel pagination

How do I remove the previousbutton with laravel pagination? https://i.gyazo.com/741444ce145abbd48a46e20e8cd74e46.png Here is my code and it doesn't work. The previous button is still displayed. a[rel="prev"] { display: none !important; }

ilex01's avatar
ilex01's avatar jlrdw4yrs agoCode Review
2
1
Last reply by jlrdw 4yrs ago
binggle's avatar

Looking for onEachSide on Inertia Vue Pagination.

hi. Isn't there something like 'onEachSide' on Inertia Vue Pagination. ? Or how can I use 'onEachSide' of Laravel on Inertia ?

binggle's avatar
binggle's avatar binggle4yrs agoInertia
1
1
Last reply by binggle 4yrs ago
MrMooky's avatar

Middleware $request->merge with Livewire pagination

I have a Middleware where I need to check the current "base" and whether or not the current user has access to it. If the user has access, I merge it with the current request so I can access it in my controllers. The part in my Middleware looks like this: $request->merge([ 'base' => $base, ]); return $next($request); That works perfectly fine. But if there

MrMooky's avatar
MrMooky's avatar stellaproj...4yrs agoLivewire
2
1
Last reply by stellaprojects 4yrs ago
ene's avatar

pagination not working

pagination isnt working when i click next , i have about 50 users but pagination not going to the next page <?php namespace App\Http\Livewire; use App\Models\User; use Livewire\Component; use Livewire\WithPagination; class AdminUser extends Component { use WithPagination; public bool $bulkDisabled = true; protected $rules = [ 'user.name' =>

ene's avatar
ene's avatar ene4yrs agoLivewire
6
1
Last reply by ene 4yrs ago
andrecuellar's avatar

Issue with LiveWire Pagination

Hello, I'm trying to paginate items in a livewire component, I have this query protected $listeners = [ 'franchises:coords' => 'getFranchises' ]; use WithPagination; public $franchiseList; public function render() { return view('livewire.franchise-list'); } public function getFranchises($coords) { if ($coords) { $latitude = json_decode($c

andrecuellar's avatar
andrecuellar's avatar andrecuell...4yrs agoLivewire
3
1
Last reply by andrecuellar 4yrs ago
spAo's avatar

Pagination problem

Hello all! I'm trying to use pagination and it's works fine. But when i add orderBy something is going wrong... Some results partly occurs again when i click on next page... So how can i add orderBy and remove this problem?

spAo's avatar
spAo's avatar spAo4yrs agoLaravel
7
1
Last reply by spAo 4yrs ago
Deekshith's avatar

Add pagination to one to many relationsship

i have a query like below, $testdetail = Test::with(['offlineconvertedtests.userdet.userregistereddetail' => function($q) use($coursedetails) { $q->where('course_id',$coursedetails->course_id) ->whereNotNull('registration_number'); }])->with(['offlineconvertedtests.roomslotdet'])->where('test_code',$testcode)->where('course

Deekshith's avatar
Deekshith's avatar Tray24yrs agoLaravel
3
1
Last reply by Tray2 4yrs ago
Deekshith's avatar

Use pagination with DB:select()

i have a query like below, $notattemptedquestions = DB::select( DB::raw("SELECT * FROM questions WHERE test_id = :test_id and active = 1 and question_id NOT IN ( SELECT question_id from user_answers where user_test_id = :user_test_id )"), array( 'test_id' => $test_id, 'user_test_id' => $user_test_id, )); I want to add pagination in the

Deekshith's avatar
Deekshith's avatar Deekshith4yrs agoLaravel
4
1
Last reply by Deekshith 4yrs ago
mani786's avatar

Larave; Pagination

public function search(Request $request) { $search = $request->input('search'); $category = $request->input('category'); $results=DB::table('products') ->where('name', 'like', "%{$search}%") ->select('products.*') ->groupBy('name') ->where('status','=','on') ->paginate(12); $products = $results; $type=$r

mani786's avatar
mani786's avatar mani7864yrs agoLaravel
3
1
Last reply by mani786 4yrs ago
Alewa's avatar

Laravel 8 pagination link error

I am having this laravel 8 error Method Illuminate\Database\Eloquent\Collection::links does not exist. (View: C:\xampp\htdocs\ramiras\resources\views\products.blade.php), I am not using {{ $products->links() }} and i don't want to use pagination but i am having link error. My controller <?php namespace App\Http\Controllers; use App\Models\Product; use App\Models\Categor

Alewa's avatar
Alewa's avatar Alewa4yrs agoLaravel
2
1
Last reply by Alewa 4yrs ago
webfuelcode's avatar

API call with pagination

This is JSON { "status":"success", "data":{ "stats":{"total":12643,"offset":0,"limit":50,"order":"desc","totalMarkets":83232}, "base":{"symbol":"USD","sign":"$"}, "photos":[{"id":1,.............................

webfuelcode's avatar
webfuelcode's avatar jlrdw4yrs agoLaravel
1
1
Last reply by jlrdw 4yrs ago
eleven0's avatar

Pagination on a Custom Function of a Model

Hello all, I have a simple function (see below) in a model, i render content based on who the user is. public function customcontent($userid) { $user = User::where('id', $userid)->sole(); if ($user->xmuser() == true) { return $this->customdocs->sortByDesc('created_at'); } if (count($user->xonly) > 0) {

eleven0's avatar
eleven0's avatar eleven04yrs agoLaravel
4
1
Last reply by eleven0 4yrs ago
mittalkhuthiya's avatar

Laravel 8 ibuit pagination and search vs datatable

Hi, I am new to laravel 8 , I am trying to figure out which is best way to implement he records from database which requires search and pagination both? Which will will give best performance Datatable or inbuilt queries from laravel?

mittalkhuthiya's avatar
mittalkhuthiya's avatar Tray24yrs agoLaravel
3
1
Last reply by Tray2 4yrs ago
larabeginner22's avatar

How to add simple pagination on search result?

The search form is on my navbar <form action="{{ request()->path() == 'tasks' ? '/task/search' : (request()->path() == '/' ? '/dashboard/search' : (request()->path() == 'users' ? '/user/search' : (request()->path() == 'roles' ? '/role/search':''))) }}" method="GET" role="search" class="form-inline mr-auto" style="margi

larabeginner22's avatar
larabeginner22's avatar Tray24yrs agoLaravel
1
1
Last reply by Tray2 4yrs ago
chinh2597's avatar

Cursor pagination add orderBy condition lead to error with old cursor

In the beginning, I'm using orderByDesc("id")->cursorPaginate(10) to create pagination, but after that i need to sort by another field (for example: score, this field is not unique) so i change query like: orderByDesc("score")->orderByDesc("id")->cursorPaginate(10). It work fine if client is new, but with exist client, their cursor paramet

chinh2597's avatar
chinh2597's avatar chinh25974yrs agoLaravel
2
3
Last reply by chinh2597 4yrs 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.