Well apparently version 5.4 and version 5.6 has a bug in pagination. Would have to check GitHub.
But all I know is @hadesunseenn model and controller code works in version 5.5.
But I did not use that view code.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Well apparently version 5.4 and version 5.6 has a bug in pagination. Would have to check GitHub.
But all I know is @hadesunseenn model and controller code works in version 5.5.
But I did not use that view code.
I also tried it in version 5.5 during the upgrade process, no luck... I am going to copy my whole project and delete every file one by one tomorrow to find the issue. A college of mine said, it was working some weeks ago and we haven't touched the vendor folder since. Has to be caused by some changed configuration or something I am haven't thought about yet. I'll post updates as soon as I succeed in any way!
@jlrdw there is just foreach loop and the pagination links in my view. So may be you are right about bug in laravel versions. I will check too. Thanks.
I have this
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class LabTest extends Model
{
protected $table = 'labs';
protected $fillable = [
'user_id', 'test_name'
];
public $timestamps = [];
}
only difference is I also have
public $timestamps = [];
But I commented out, still works.
Guys
You don't have to mess about with views etc. Just call your route and add ?page=1, ?page=2, ?page=3 etc
You can test this with just the controller.
Check the query being performed. It should have limit and offset
Talk of bugs is just silly. This is being used by 10's of thousands of projects.
@hadesunseenn do a simple troubleshooting first try to do the same as you did with this function with other page function to see if its working there or not once try to do like this without ordering
$tests = LabTest::paginate(2); return view('labTest.index', compact('tests'));
see if you get your result or no if you did with other function and page and had no error and expected result so the problem is with your table or model and function you are trying to get data.
once please drop here your complete function, route, model, migration
then i can tell you where is the problem.
thank you
My current code:
Route::get('ho', 'GeneralController@test');
class GeneralController extends Controller {
public function test() {
DB::enableQueryLog();
$lala = DB::table('products')
->select('id')
->simplePaginate(5);
dd(DB::getQueryLog());
}
output is always the same, regardless of a manually set "page" parameter in the URL
array:1 [▼
0 => array:3 [▼
"query" => "select `id` from `products` limit 6 offset 0"
"bindings" => []
"time" => 138.95
]
]
pagination is for eloquent models
I am using it just like they do in the doc with a mysql db query: https://laravel.com/docs/5.4/pagination
I found the issue.... input (get) parameters were not received by the route, so I found a misconfiguration in my htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
I changed it to the example code in the laravel git repo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
And now it is working, thank god :) Thank you all for your help!
And don't ask me, why the last line looked like this on our server...
@FeBe95 Worked for me. Thanks
Hi, @hadesunseenn
Your answser save my day! Thanks!
My pagination isn't working after I move all website to new server and upgrade php from 5.0 to 7.0. It's lucky to see your answer!
superb.... my issue also resovled. Thank GOD
I have same error. Try to take off your server (nginx/apache) then run "php artisan serve" and check paginate. Probably your problem with Nginx configuration. try_files $uri $uri/ /index.php?$query_string;
I think it is big issue of pagination class laravel should look it carefully & fixed it, i am using laravel since 6 years but i just also stuck with this issue. seriously pagination numbers now showing only just showing next,prev links
@gajendra@7590 no. it works fine in every case
First of all goto this file and write following code in boot() method. public function boot() { Paginator::useBootstrap(); } and add Paginator namespace at above class defined, like this: use Illuminate\Pagination\Paginator;
Please or to participate in this conversation.