creativetimofficial / ct-argon-dashboard-pro-laravel

Argon Pro Dashboard For Laravel Framework 11.x and Up
http://argon-dashboard-pro-laravel.creative-tim.com/
32 stars 13 forks source link

Cant make page number of datatable dynamic [premium support] #45

Closed heshamwatany closed 1 year ago

heshamwatany commented 1 year ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Expected Behavior

To add laravel way of pagination links in blade and it works normally

Current Behavior

it is not sync with the current implementations, the page number in items sample page is not dynamic and cant sync it with normal pagination

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Add {{ $users->links() }} under table of page items
  2. Number of pages is the same

Context

Failure Logs

Please include any relevant log snippets or files here.

teamupdivision commented 1 year ago

Hello,

Thank you for using creative TIM!

You should be able to find what you need in the original code of the template. You can find the pagination that works here --> https://www.creative-tim.com/live/argon-dashboard-pro-laravel

Best.

heshamwatany commented 1 year ago

The pagination exists in form of HTML not in laravel way of implementation

teamupdivision commented 1 year ago

Now the project is using the pagination from Datatables Bootstrap5 as you can see in the index.blade.php of category, tag, user, item and role files. To change to Laravel pagination you will need to follows some steps:

  1. In app/Providers/AppServiceProvider.php add at the top of the file use Illuminate\Pagination\Paginator;

and in the function boot add this change public function boot() { Paginator::useBootstrap(); }

  1. For your table, go to the controller associated with it, for example if I want to add Laravel pagination to User table you will got to app/Http/Controllers/UserController and in the funtion index I will make the update to public function index(User $model) { $this->authorize('manage-users', User::class); return view('laravel.users.index', ['users' => $model->paginate(5)]); }

  2. Now you can go to your table in resources/laravel/users/index.blade.php and add after you closing tab for {{ $users->links() }}

  3. In the same resources/laravel/users/index.blade.php file, where the @push('js') takes place you will need to remove the pagination from the Datatable Bootstrap 5 by adding paging: false`` like this

    Let us know if that helps.

heshamwatany commented 1 year ago

It works thanks you very much