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

binggle's avatar

Is it possible to use SortBy with pagination ?

I have to get manager list using SortBy with Accessors. Accessors are from relation model. And I need paginations too. But SortBy need collection not query. I can not call SortBy before calling cursorPaginate, I guess. How can I use Pagination with SortBy ? source Code is following. Manager Model class Manager extends Model { protected $appends = [ 'avg', 'avg_age'

binggle's avatar
binggle's avatar binggle4yrs agoEloquent
3
1
Last reply by binggle 4yrs ago
electric18's avatar

Load More Pagination

I have a server-side rendered app that hits an external API and shows some data on a page. I would like to add some pagination functionality where a user can click read more and more results are appended to the same page. The problem is I have not found way to append the results to the same page. I am able to receive more results just by changing the query parameters and hittin

electric18's avatar
electric18's avatar electric184yrs agoRequests
12
1
Last reply by electric18 4yrs ago
francis_sebin_fernandez's avatar

Via Relation pagination count drop down/ per page option (Laravel Nova))

Hai, Thanks in advance! I have a situation in which I need to create a per-page dropdown for the relatable resources. In Nova by default, we have a per-page dropdown created by the following static array => public static $perPageOptions = [25, 50, 100]; What I'm trying to implement is the same option for the relatable resource( created by Hasmany::make(....) ). I found a sta

francis_sebin_fernandez's avatar
francis_sebin_fernandez's avatar francis_se...4yrs agoNova
0
1
GregorSams's avatar

Use Pagination on Query Builder Instance

I am using Laravel Framework 8.62.0 and PHP 7.4.20. I get the following error: Call to undefined method Illuminate\Database\Eloquent\Builder::links() (View: /home//Code/test_project/resources/views/index.blade.php) I have a view that has uses 3 simple filters. To display the view without filters I use the following: public function getSearchView() { try {

GregorSams's avatar
GregorSams's avatar jlrdw4yrs agoLaravel
2
1
Last reply by jlrdw 4yrs ago
ynoth25's avatar

Laravel Pagination with VueJS

I can retrieve data from controller using pagination, I can also display the data. My problem is I have a custom pagination template and it has 3 divs and I can only loop inside 1 div and I can 't use my custom 'Previous & Next button' <nav class="border-t border-gray-200 px-4 flex items-center justify-between sm:px-0" aria-label="Pagination">

ynoth25's avatar
ynoth25's avatar Sinnbeck4yrs agoVue
5
1
Last reply by Sinnbeck 4yrs ago
lavelforum's avatar

Pagination appends and route

When we want to keep the parameters within the pagination, we can do an append : $informations->appends(Request::except('page', '_token'))->onEachSide(1)->links() So, the links under pagination looks like : http://localhost:81/portail/actualite?theme=0&domaine=1&annee=2020&nombre_resultat_page=10&page=2 Is it possible to have links like a route way ?

lavelforum's avatar
lavelforum's avatar lavelforum3yrs agoLaravel
1
1
Last reply by lavelforum 3yrs ago
abkrim's avatar

Pagination published not work

I've run php artisan vendor:publish --tag=laravel-pagination for publish pagination Also forced model to use a pagination theme with protected string $paginationTheme = 'tailwind'; That is tested working if change for example to 'simple-tailwind` I have edited vendor/pagination/tailwind.blade.php for correct some issues with tailwindss But this approach not works. What is my m

abkrim's avatar
abkrim's avatar abkrim4yrs agoLaravel
2
1
Last reply by abkrim 4yrs ago
Daniel-Pablo's avatar

livewire pagination disappear when i put another livewire component inside the loop

Hi , im facing a problem, i make a livewire pagination but this pagination fails or disappear when i put another livewire component inside the loop. Hope some can help me, thanks. Father componen main loop: <div> @foreach($comments as $comment) <p class="text-xs">{{$comment->user_comment}} </p> @endforeach {{ $comments->links() }} </div>

Daniel-Pablo's avatar
Daniel-Pablo's avatar Arius Tigg...4yrs agoLivewire
4
1
Last reply by Arius Tigger 4yrs ago
Rarepyre's avatar

CREATE PAGINATION VIEW FROM JSON API

Hi! thank for clicking this discussion. I have some problem when i try to create pagination in Laravel project, i have JSON data from my Lumen project. Here my Lumen JSON Response: // 20211004195501 // http://localhost:8001/article/list?page=7 { "status": "success", "data": { "current_page": 7, "data": [ {

Rarepyre's avatar
Rarepyre's avatar Rarepyre4yrs agoLaravel
2
1
Last reply by Rarepyre 4yrs ago
Pranam's avatar

Pagination with join table not working getting duplicate value with groupBy or unique() or distinct().

Pagination with multiple tables joined not working to get the unique value in the query and only working with get() method. I have also orderBy in the query. Unique value is not achieved and in the example below using unique with paginate i am getting 5 unique items and with get i am getting 9 unique items and while using groupby and distinct no unique selected values are found

Pranam's avatar
Pranam's avatar Pranam4yrs agoEloquent
2
1
Last reply by Pranam 4yrs ago
jucan's avatar

Livewire Pagination on UI Tabs not working

I have a livewire pagination problem, please help. On first page the pagination is working fine. On clicking to the subsequent pages, nothing shows. My code is below public $perPage = 10; protected $paginationTheme = 'bootstrap'; /** * Pagination View */ public function paginationView() { return view('vendor.livewire.bootstrap'); } publ

jucan's avatar
jucan's avatar jucan4yrs agoLivewire
0
1
vandan's avatar

laravel pagination without page reload works?

hello i m confuse for i want data without page reload on laravel paginate method in default laravel pagination is working with page reload when click on next page but i want without page reload its pagination working so its possible or not ?

vandan's avatar
vandan's avatar van13104yrs agoLaravel
2
1
Last reply by van1310 4yrs ago
Patel's avatar

Laravel Pagination using array and without refreshing page.

Hi, I have been trying to implement laravel pagination with an array and it refreshes the page and I dont want that to happen as I have some form fields and on the click of the button it sends a post request to get the records in an array and I display them on the table. With the default pagination it displays the links but when I click on them it refreshes the page and sets th

Patel's avatar
Patel's avatar jlrdw4yrs agoLaravel
8
1
Last reply by jlrdw 4yrs ago
shiro_'s avatar

Laravel Add Pagination To External Api Response

Hi, i am trying to consume the marvel api using the server side method. Unfortunately, the api does not have pagination, so i am trying to create that so that i can easily display all pages on the front end. For now, the data only displays the fist page, and i would like to display data as it is looped from each page. My code currently looks like this : public function get_char

shiro_'s avatar
shiro_'s avatar jlrdw4yrs agoLaravel
1
2
Last reply by jlrdw 4yrs ago
Villdar's avatar

Pagination and sort

I'm trying to render different posts based on a request in my react component using axios, function hideOnClick(id) { setHide({value: id}) console.log(id); const body = { 'chordId' : id, } axios.post(url, body) .then(function(response){ console.log(response.data); // Create a new element var newNode

Villdar's avatar
Villdar's avatar Villdar4yrs agoLaravel
0
1
Marco Aurelio's avatar

Lean controllers/business logic on services and filtering, sorting, pagination methods on controllers

I'm currently reading about "Lean controllers"/"Business logic on services" and trying to refactor a legacy code. However I am struggling to apply what is taught in the tutorials on real code. Online examples are simple. But in real code, I have controllers that need to use filtering, sorting, filtering, sorting, pagination (and the fact that some of these e

Marco Aurelio's avatar
Marco Aurelio's avatar bugsysha4yrs agoCode Review
5
1
Last reply by bugsysha 4yrs ago
spAo's avatar

Laravel pagination

hello i'm trying to do pagination to category page but its errors web Route::get('/category/{slug}/{page?}', [WebController::class, 'category'])->name('category'); category model public function articles() { return $this->hasMany(Article::class, 'category_id', 'id')->orderBy('published_at', 'Desc'); } controller public function category($slug, $page

spAo's avatar
spAo's avatar jlrdw4yrs agoLaravel
5
1
Last reply by jlrdw 4yrs ago
vandan's avatar

laravel pagination not working after ajax call

hii i used laravel pagination but when i filter data means ajax call then laravel pagination not working properly how manage this here my controller file public function index() { $events = Event::paginate('9'); return view('event.index',compact('events')); } //ajax filter public function advancefilter(Request $request) { $html = ''; $Array = [];

vandan's avatar
vandan's avatar van13104yrs agoLaravel
1
1
Last reply by van1310 4yrs ago
Hekmatyar's avatar

Livewire Pagination - action's not working

Why there is so much problems with this pagination from livewire? i have been see many topics of this.. and srsly i don't get it.. https://i.imgur.com/PENGFjf.gifv <- problem if i go manualy and i write "?page=2" in url adress it is working, but i don't have any actions inside, clicking in pagination buttons | "laravel/framework": "^8.54", | &qu

Hekmatyar's avatar
Hekmatyar's avatar teos_974yrs agoLivewire
16
2
Last reply by teos_97 4yrs ago
johnw65's avatar

Datatable Server-Side Pagination for Newly Added Record

I'm currently using Datables 1.10 and is using Server-Side with Pagination (which is dynamic based on the screen size using PageResize plugin: https://datatables.net/blog/2015-04-10 ). To show the selected row, I am using row().show() plugin: https://datatables.net/plug-ins/api/row().show() My customer is requesting that once an user adds a new record, it should take the user

johnw65's avatar
johnw65's avatar johnw654yrs agoLaravel
4
1
Last reply by johnw65 4yrs ago
FutureWeb's avatar

Pagination and Pluck not plucking entire collection

is there a way to pluck values before pagination? I am only getting the names from the first 20 $users = User::where('role_id','=',1)->paginate(20); $userNames = $user->pluck('name')->unique();

FutureWeb's avatar
FutureWeb's avatar Snapey4yrs agoLaravel
7
1
Last reply by Snapey 4yrs ago
zappellin's avatar

Livewire pagination shrinking

I have a weird issues when I try to use bootstrap pagination template for my livewire table. It's look like this : https://drive.google.com/file/d/1CeSY7YdGGKSScQIqPmG-ZVE-81xguYH5/view?usp=sharing I can't manage to find why it's like this, and I would love to have some suggestion.

zappellin's avatar
zappellin's avatar zappellin4yrs agoLivewire
2
1
Last reply by zappellin 4yrs ago
untymage's avatar

How to use Cursor Pagination in non web app ?

I want to paginate my data in none web application using cursor pagination, But how can i use it ? for example how can i go to the next page or prev page ? $c = DB::table('users')->orderBy('id')->where('name', 'like', 'alex%')->cursorPaginate(); $c->nextCursor()->encode() //eyJpZCI6MTwekxNSwiX3BvaWw50c1RvTmV4dEl0ZW1zIjp0cnVlfQ how to use that hash to go next pa

untymage's avatar
untymage's avatar jlrdw4yrs agoLaravel
1
2
Last reply by jlrdw 4yrs ago
Kikismedia's avatar

pagination next button not working

please what am i doing wrong pagination isnt working and im not getting any error , next button isnt working class PostsIndex extends Component { // use WithPagination; use WithPagination; public $status; public $school; public $filter; public $search; protected $queryString = [ 'status', 'school', 'filter', 'search',

Kikismedia's avatar
Kikismedia's avatar Kikismedia4yrs agoCode Review
3
1
Last reply by Kikismedia 4yrs ago
Albertopeinado's avatar

Pagination data not included in API Resources

I have no clue what could be happening here. I have ProductCollection that returns the pagination data correctly if the data is returned from the route directly. Route::get('/products', function () { return new ProductCollection(Product::paginate()); }); However, if the data is returned from controller as a json response like this, it does not include the pagination data: retur

Albertopeinado's avatar
Albertopeinado's avatar martinbean4yrs agoLaravel
1
1
Last reply by martinbean 4yrs ago
fanpero87's avatar

Pagination includes _token string

Hello, I'm adding pagination to my view but for some reason the URL string includes a "_token" string. How can I remove that? Here is How my controller looks like: public function index($client_id, Request $request) { $client = Client::where('id', $client_id)->first(); if ($request->search) { $extensions = Extension::query()

fanpero87's avatar
fanpero87's avatar MichalOrav...4yrs agoLaravel
1
1
Last reply by MichalOravec 4yrs ago
PaulCatalin97's avatar

JavaScript Pagination when 1 page shows page previous-1-1-next

I'm using a table to show the values from my data base and I use a JQuery for pagination but when I use the search bar and it only shows data for 1 page, the pagination shows Previous pg1 pg1 Next and the second button I don`t need to be shown When it shows data for 2-3-4 pages works corectly Here is the code for the table and the buttons function getProducts() { $.

PaulCatalin97's avatar
PaulCatalin97's avatar jlrdw4yrs agoJavaScript
1
1
Last reply by jlrdw 4yrs ago
afoysal's avatar

Pagination in HTTP Client

I am using below code as HTTP Client. $response = Http::get('http://example.com'); How can I add Pagination here ?

afoysal's avatar
afoysal's avatar SilenceBri...4yrs agoLaravel
1
1
Last reply by SilenceBringer 4yrs ago
princewillopah's avatar

Chrome Back button is not preserving the url history when using Ajax for pagination

Hey guys, pls help me out. i recent used ajax for my laravel pagination. Whenever i click he back button. it does not go back to the page i am coming from. it goes back to page 1. let me Illustrate this clearly. (1) i have a list of items paginated with jquery ajax. (2) when i visit the 5th page( for example) and click an item to view details of that item and decided to click t

princewillopah's avatar
princewillopah's avatar princewill...4yrs agoCode Review
3
1
Last reply by princewillopah 4yrs ago
magi010731's avatar

Duplicate Records with pagination

Greetings, I hope someone can help me. I am having an issue with duplicate records being included in my search while doing several joins and using pagination. Here is my query: $query = Property::query(); $query->join('calcs', 'properties.id', '=', 'calcs.property_id')->whereHas('calcs'); $query->leftJoin('transactions', 'properties.id', '=', 'transactions.property_id'

magi010731's avatar
magi010731's avatar magi0107314yrs agoEloquent
3
1
Last reply by magi010731 4yrs ago
PaulCatalin97's avatar

Pagination in laravel with ajax/json

I have a table and I'm showing some data from the database to a table with and method. but I wanna paginate in the view and I really don't know how. What should I do to the view to show the pagination with buttons for each page/first page and last page? here is my controller public function getProducts(Request $request) { return response()->json(Product::with('s

PaulCatalin97's avatar
PaulCatalin97's avatar PaulCatali...4yrs agoLaravel
2
1
Last reply by PaulCatalin97 4yrs ago
Rory Gonzalez-Brown's avatar

Laracasts Bug? Discussions Search Query Pagination

@JeffreyWay I was searching for a word in the discussions section of the Laracasts website and noticed that each time I clicked a pagination link to the next page of results the search query is removed from the URL. I have been adding the page query manually for now in order to retain the search filter queries in the URL. Hope this is useful.

Rory Gonzalez-Brown's avatar
Rory Gonzalez-Brown's avatar Rory Gonza...4yrs agoFeedback
0
1
dipherent's avatar

Pagination: How to go to top after clicking next or previous?

Hi friends, I have implemented pagination in livewire use WithPagination; However, because I have a long list in the page, I need the user to be able to go to the top of the page after clicking next or previous. How do I do this please? Thanks a lot,

dipherent's avatar
dipherent's avatar dipherent4yrs agoLivewire
0
1
channaveer's avatar

Laravel Pagination Not Working

Hi everyone, Laravel pagination is not working in one of my controller. In other controllers, it's working totally fine. Following is the dump of my controller code try { $courseCategory = (new CourseCategoryService)->getByColumnName('slug', 'course'); $courseChannels = Channel::with('course') ->where('course_category_id', $

channaveer's avatar
channaveer's avatar channaveer4yrs agoLaravel
2
1
Last reply by channaveer 4yrs ago
andiliang's avatar

lazy loading iamge not working on pagination

I have gallery model , which will output all the iamge path ,so I make it with pagination , base on the view point each row displays 3 pics of image, I wanna tp implement lazt loading imag effect, which image at the bottom wont be load it until us scroll the page. I use lozad js , and its not working , then I use some hand write js its working but only if I output image one by

andiliang's avatar
andiliang's avatar bugsysha4yrs agoJavaScript
1
1
Last reply by bugsysha 4yrs ago
lordisp's avatar

Prevent Livewire Pagination from submittin a form

I have a stacked form (i shorted the code to the minimum) which has checkboxed from a model. The list has a pagination (I'm using the WithPagination traid) The problem is now, when I click on a page link, the form gets submited. I've tried to prevent this by adding the prevent to <button wire:click.prevent="nextPage"> This helped but now the submit button at the

lordisp's avatar
lordisp's avatar lordisp4yrs agoLivewire
1
1
Last reply by lordisp 4yrs ago
GodziLaravel's avatar

how to keep pagination after transform() ?

Hello , this is my code : $exceptions = [1,4,7,88,5,8] $data = \App\User::select(['id','name','city','post_code', 'email'])->paginate(10) ->transform(function($item) use($exceptions ){ if (!in_array($item->id ,$exceptions )){ $item->email = null; } return $item; }); return $data; The problem is return $data; retu

GodziLaravel's avatar
GodziLaravel's avatar webrobert4yrs agoGeneral
6
1
Last reply by webrobert 4yrs ago
spycrabo's avatar

Pagination inside JsonResource

Is there any ready mechanism in Laravel to organize pagination inside json resources? For example we have some models structure - Parent has many Children. Now we need to create API method which would return collection of Parent models and each Parent model will contain its Children collection. For sure we are using pagination for Parent collection and return json like: { &qu

spycrabo's avatar
spycrabo's avatar automica5yrs agoLaravel
1
1
Last reply by automica 5yrs ago
bhojkamal's avatar

What would be the best for pagination and search and create pdf table data for Laravel 8, vue 3 and bootstrap combination

Hello, What would be the best practice to use for pagination, search and create export pdf, excel for the table's data for the application combination of Laravel 8, Vue 3 and bootstrap 5. Some options are: Develop pagination, search and create export data from scratch but it will definitely take long time. Use datatable of jquery but worried about the usage of Vue.js 3 and jQu

bhojkamal's avatar
bhojkamal's avatar bhojkamal5yrs agoGeneral
4
1
Last reply by bhojkamal 5yrs ago
lvlNewbie's avatar

foreach varibale with alpine breaks livewire pagination

Hi, I have a model to edit post, where the post id is assigned to edit modal from a button like this @click.prevent="$dispatch('edit-post-modal', { reply_id:'{{$comment->id}}' })" The above works fine as for editing the post, but this breaks Livewire pagination, which complains as Uncaught (in promise) DOMException: String contains an invalid character when clickin

lvlNewbie's avatar
lvlNewbie's avatar lvlNewbie5yrs agoLivewire
2
1
Last reply by lvlNewbie 5yrs ago
theProfit's avatar

DB Pagination RESTFULL + Extra query's

Hi Everybody, When you have a restfull api and you do this by Pagination is there a proper way to use extra querys this because paginate will also make the urls for next page ect. witch if you use ?language=NL and some other parameters this must also go with the next page.

theProfit's avatar
theProfit's avatar hesselkram...5yrs agoGeneral
5
1
Last reply by hesselkramer 5yrs ago
Tithira's avatar

Axios get and pagination offset returning duplicate values

I am broadcasting an event trigger upon user creating a post with pusher, and I'm receiving it in a vue template. For easiness I have added infinite loading. First loading the posts from the DB and i mounted an Echo listener and pushing to the returned posts array. However when get request trying to offset the results (pagination to only 5 posts) the 6th result is duplicated (2

Tithira's avatar
Tithira's avatar Tithira5yrs agoCode Review
3
1
Last reply by Tithira 5yrs ago
Nospoon's avatar

Can't change default pagination view

I'm trying to make a small change to the default pagination component. Followed the documentation, after publishing the vendor views with php artisah vendor:publish --tag=laravel-pagination I modified the tailwind.blade.php file, but the changes are not being applied, no matter how many times I clear the cache and reload the browser, it still doesn't seems to use the default co

Nospoon's avatar
Nospoon's avatar Nospoon5yrs agoLaravel
3
1
Last reply by Nospoon 5yrs ago
ihor1976's avatar

pagination from the last page

Good day. I have a large list of buyers, I have provided pagination for this, but I need pagination to start from the last page, how to do this ??, Thanks in advance for your answers and good luck in all your projects))

ihor1976's avatar
ihor1976's avatar ihor19765yrs agoLaravel
5
1
Last reply by ihor1976 5yrs ago
DianaAli's avatar

How to get total numbers in laravel pagination?

I'd like to show like this in laravel pagination. Showing from to to of total entries Here is from, to , total are not page number. They are items number. Please reply me if you know.

DianaAli's avatar
DianaAli's avatar jlrdw5yrs agoLaravel
10
1
Last reply by jlrdw 5yrs ago
jerexbambex's avatar

Laravel 8 Pagination not showing in View

Pagination links not showing in view when I use paginate() but it only shows "Previous" and "Next" when I use simplePaginate(). Please I need help. It's still tailwind CSS that I am using.

jerexbambex's avatar
jerexbambex's avatar vlade223yrs agoLaravel
16
1
Last reply by vlade22 3yrs ago
Deekshith's avatar

add condition along with pagination for one to many relationsip.

i have a query like below, $cat = Taxonomy::category()->slug('current-affairs-2')->with(['posts'=>function($q) { $q->where('status', 'publish') ->whereDate('post_date','2021-03-03'); }])->first(); return $cat->posts()->paginate(10); But here "where" condition is not working. how to add pagination along wi

Deekshith's avatar
Deekshith's avatar Deekshith5yrs agoLaravel
9
1
Last reply by Deekshith 5yrs ago
Dhruv Sompura's avatar

Laravel Pagination onEachSide is not working

I am fetching users list from database, and i added this code, pagination is working fine but onEachSide is not working $users = User::paginate(5); {{ $users_list->onEachSide(2)->links() }}

Dhruv Sompura's avatar
Dhruv Sompura's avatar neilstee5yrs agoLaravel
7
1
Last reply by neilstee 5yrs ago
wtd47's avatar

Laravel Pagination jump the page

How do pagination jump the page, I want to have a blank to fill in page then go to the page. {{ $products->appends(request()->all())->links("pagination::bootstrap-4") }}

wtd47's avatar
wtd47's avatar jlrdw5yrs agoLaravel
1
1
Last reply by jlrdw 5yrs ago
uniqueginun's avatar

Livewire pagination issue

I'm using livewire pagination it works but sometimes I have to click twice to navigate to other page. I swear to GOD it works fine if I cleared the log file before each click !!!!!!!!

uniqueginun's avatar
uniqueginun's avatar chaudigv5yrs agoLivewire
6
1
Last reply by chaudigv 5yrs 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.