Laravel 5 Pagination example

Laravel 5 Pagination example

In this post we will give you information about Laravel 5 Pagination example. Hear we will give you detail about Laravel 5 Pagination exampleAnd how to use it also give you demo for it if it is necessary.

In this tutorial you can learn how to add simple pagination in your blade file. If you are beginners then it can help you. Laravel 5 provide its own method for pagination. But if you are work on code PHP then you have to write long code for pagination and render view etc but in Laravel it is very simple so let’s select data following way in Controller.

Controller File:

public function getUser()

{

$data = User::paginate(10);

return view('users.index',compact('data'));

}

In above example you can see now it will return pagination with 10 records if you want to 5 or 15 etc then you can change argument. Now we have to render pagination view so, let’s see.

Blade File:

Also see:Laravel 5 – elasticsearch with pagination example

@extends($theme)


@section('content')


<table >

<thead>

<tr>

<th>Name</th>

<th width="300px;">Action</th>

</tr>

</thead>

<tbody>

@if(!empty($data) && $data->count())

@foreach($data as $key => $value)

<tr>

<td>{{ $value->name }}</td>

<td>

<button >Delete</button>

</td>

</tr>

@endforeach

@else

<tr>

<td colspan="10">There are no data.</td>

</tr>

@endif

</tbody>

</table>


{!! $data->render() !!}


@endsection

Hope this code and post will helped you for implement Laravel 5 Pagination example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  6  =  12

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US