Laravel 5 Pagination with array

Laravel provides pagination for Eloquent results out of the box, but for custom data, we need to do the pagination manually.

In this tutorial, I’ll use Laravel5 LengthAwarePaginator class to show you how you can create a paginated list of results from an array of data.

Here is the Script –

Controller – app/Http/Controller/ItemsController.php

Here is the view file

Define your route as shown below –

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.


  1. hey can u help me
    how array like this
    $data[‘a’]=DB::select(“select * from table_name);
    $data[‘b’]=DB::select(“select * from table_name);

    return view(‘view.home’,$data);
    how to add pagination like you do it

    1. $data[‘a’] = DB::table(‘table_name’)->select(‘column’)->paginate(3);
      return view(‘view’, [‘data’ => $data]);

      in blade use {{ $data[‘a’]->links() }}

  2. My project uses CURL to get all data through URL API. I am looking for a solution. Thanks man. Thanks to tutorials, work it. Thanks from Vietnam

  3. I don’t even know how I ended up here, but I thought this post was
    good. I don’t know who you are but certainly you
    are going to a famous blogger if you are not
    already 😉 Cheers!

Leave a Reply

Your email address will not be published.