Laravel 6 Pagination Link Customizations Example

Today, We want to share with you Laravel 6 Pagination Link Customizations Example.In this post we will show you Laravel Paginate Collection or Array, hear for Laravel pagination with array instead of collection we will give you demo and example for implement.In this post, we will learn about Laravel 6 Collections: Paginating Collections With forPage with an example.

Laravel 6 Pagination Link Customizations Example

There are the Following The simple About Laravel 6 Paginate with Collection or Array Full Information With Example and source code.

As I will cover this Post with live Working example to develop Custom Pagination View in Laravel 6 With Arrays, so the pagination in query laravel is used for this example is following below.

Step 1: Laravel Create Route

routes/web.php

Route::get('paginate', 'TransController@index');

Step 2: Laravel 6 Create Controller

app/Http/Controllers/TransController.php

1, 'title'=>'FOX NEWS'],
            ['id'=>2, 'title'=>'Lyme disease'],
            ['id'=>3, 'title'=>'Chronic Mono'],
            ['id'=>4, 'title'=>'lyme disease symptoms'],
            ['id'=>5, 'title'=>'What is Lyme disease'],
            ['id'=>6, 'title'=>'BBC news'],
            ['id'=>7, 'title'=>'Valencia vs Real Madrid'],
            ['id'=>8, 'title'=>'Grimes'],
            ['id'=>9, 'title'=>'Elvis Presley'],
            ['id'=>10, 'title'=>'elvis birthday'],
        ];
  
        $myGoogleTrandObj = collect($google_trands);
  
        $data = $this->paginate($myGoogleTrandObj);
   
        return view('paginate', compact('data'));
    }
   
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    public function paginate($items, $perPage = 10, $page = null, $options = [])
    {
        $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
        $items = $items instanceof Collection ? $items : Collection::make($items);
        return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);
    }
}

Step 3: Laravel 6 Create View File

app/Http/Controllers/TransController.php

Laravel 6 Paginate with Collection or Array - TamilRokers

@foreach($data as $trand) @endforeach
Id Title
{{ $trand->id }} {{ $trand->title }}
{{ $data->links() }}
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about convert array to pagination laravel.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment