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', '[email protected]');
Step 2: Laravel 6 Create Controller
app/Http/Controllers/TransController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Pagination\Paginator; use Illuminate\Support\Collection; use Illuminate\Pagination\LengthAwarePaginator; class TransController extends Controller { /** * The attributes that are mass assignable. * * @var array */ public function index() { $google_trands = [ ['id'=>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
<h3>Laravel 6 Paginate with Collection or Array - TamilRokers</h3> <div class="container"> <table class="table table-bordered"> <tr> <th>Id</th> <th>Title</th> </tr> @foreach($data as $trand) <tr> <td>{{ $trand->id }}</td> <td>{{ $trand->title }}</td> </tr> @endforeach </table> </div> {{ $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.