Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Engine LengthAwarePaginator not supported #2334

Open
diogo-garcia opened this issue Mar 2, 2020 · 2 comments
Open

Engine LengthAwarePaginator not supported #2334

diogo-garcia opened this issue Mar 2, 2020 · 2 comments

Comments

@diogo-garcia
Copy link

Summary of problem or feature request

Hello, I've been trying to work with Laravel 6 + Latest laravel-datatables pagination, without any lucky hehe... It seems that the available laravel-datatables engines does not include LengthAwarePaginator which is the result of the simple laravel paginate, for example:

$users = \DB::table('USERS')->paginate(15); return datatables()->of($users)->toJson();
Returns the exception: "No available engine for Illuminate\Pagination\LengthAwarePaginator"

Is there any other way to use the native paginate + laravel-datatables? If I don't use the paginate from Laravel 6 and my table has too many rows, the datatables tries to apply pagination on the navigator, and it can't handle too many rows.

@diogo-garcia
Copy link
Author

diogo-garcia commented Mar 2, 2020

I've changed the datatables.php config file to

    'engines'        => [
        'eloquent'   => Yajra\DataTables\EloquentDataTable::class,
        'query'      => Yajra\DataTables\QueryDataTable::class,
        'collection' => Yajra\DataTables\CollectionDataTable::class,
        'resource'   => Yajra\DataTables\ApiResourceDataTable::class,
        'LengthAwarePaginator' => Yajra\DataTables\PaginatorDataTable::class,
    ],

And created a Paginator class based on the Collection class and got it kind working... hehe

Gonna make some more tests...

@yajra
Copy link
Owner

yajra commented Mar 3, 2020

@diogoico good to hear that. I would gladly accept a PR for that if you would like to share your codes. :) Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants