Files
2026-07-13 15:23:29 +08:00

36 lines
1.0 KiB
PHP

<?php
namespace Modules\Common\Providers;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\ServiceProvider;
class PaginationProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
$this->app->bind('Illuminate\Pagination\LengthAwarePaginator', function ($app, $options) {
return new class(
$options['items'],
$options['total'],
$options['perPage'],
$options['currentPage'],
$options['options']
) extends LengthAwarePaginator {
public function toArray(): array
{
return [
'data' => $this->items(),
'total' => $this->total(),
'pageSize' => $this->perPage(),
'current' => $this->currentPage(),
];
}
};
});
}
}