Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5/ 5.4 paginator is not working in NGINX production environement

In my local environment i did $items = Model::paginate(10); and it worked. Then i pushed it to production and when i click on the pagination links it displays page 1 again and again. then i did dd($items). i found that the current Page property of length aware pagination is not changing when i change the address to /items?page=*. How to make current page property change accordingly or there is some thing else? thanks in advance

like image 691
Ahmed Nawaz Khan Avatar asked Jun 17 '17 07:06

Ahmed Nawaz Khan


People also ask

What is paginator in Laravel?

Laravel's paginator is integrated with the query builder and Eloquent ORM and provides convenient, easy-to-use pagination of database records with zero configuration. By default, the HTML generated by the paginator is compatible with the Tailwind CSS framework; however, Bootstrap pagination support is also available.

How do I convert a Laravel pagination result to JSON?

The Laravel paginator classes implement the Illuminate\Contracts\Support\Jsonable Interface contract and expose the toJson method, so it's very easy to convert your pagination results to JSON. You may also convert a paginator instance to JSON by returning it from a route or controller action:

Why are my tailwind classes not purging in Laravel?

If you are using Laravel's default Tailwind pagination views and the Tailwind JIT engine, you should ensure your application's tailwind.config.js file's content key references Laravel's pagination views so that their Tailwind classes are not purged: There are several ways to paginate items.

Does tailwind support bootstrap pagination?

By default, the HTML generated by the paginator is compatible with the Tailwind CSS framework; however, Bootstrap pagination support is also available.


1 Answers

I am using ubuntu 16.04 nginx server. The problem was that $_GET session variables were not being set properly. so what I did was inside /etc/nginx/sites-available/default and inside location / block/ directive I changed try_files $uri $uri/ /index.php?$query_string; to try_files $uri $uri/ /index.php?$args; and it worked. Or see Laravel 5 - NGINX Server Config Issue with URL Query Strings

like image 150
Ahmed Nawaz Khan Avatar answered Oct 29 '22 12:10

Ahmed Nawaz Khan