I want to paginate my invoices from stripe. What I did is I used a Paginator like so
$invoices = auth()->user()->invoices();
$invoices = new Paginator($invoices, 2);
$invoices->withPath('/settings/invoices');
The problem is when I paginate the invoices only the first page gets loaded and if I click on next the page stays the same, so no further invoices are loaded.
$total = $items->count(); // Specify your total here
$perPage = 10;
$currentPage = LengthAwarePaginator::resolveCurrentPage();
$currentItems = $items->slice(($currentPage - 1) * $perPage, $perPage)->values();
$invoices = new LengthAwarePaginator(
$currentItems, // The items for the current page
$total, // Total number of items
$perPage, // Items per page
$currentPage, // Current page number
['path' => LengthAwarePaginator::resolveCurrentPath()] // Path to append to pagination links
);
$invoices->appends($request->query());
return view("invoices", compact("invoices"));