Home » Php » php – paginate and display data retrieved remotely in laravel

php – paginate and display data retrieved remotely in laravel

Posted by: admin February 25, 2020 Leave a comment

Questions:

i need to display paginated list of items on a laravel blade. I have very little knowledge of laravel and php. basically Controller action will fetch data from web api, and return data retrieved to a blade view. clicking the next/previous buttons should trigger same controller action with page number/index

public function displayPaginatedData($pageIndex)
{
    $pageIndex = isset($pageIndex) ? $pageIndex : 1;
    $remoteData = remoteApiProvider::getData($pageIndex); //associative array
    return view('aBlade', $remoteData);
}

I read that i can manually create a paginator via Illuminate\Pagination\Paginator but i cannot provide the full array, too big. is there an interface that i can implement to utilize this laravel pagination + links() api?

How to&Answers: