I create a custom <select>
in order to paginate the results, but I don't know how to make usable.
I want to do the easiest way to work, and in my brain is link the paginate
method in AlumnoController
with this select
options.
Can I? Or it's harder than I want to do?
AlumnoController.php
public function index()
{
$alumnos = Alumnos::orderBy('NAME', 'asc')->paginate(30);
return view ('alumnos.index', ['alumnos' => $alumnos]);
}
index.blade.php
<table>
<thead>
<tr>
<th></th>
<th>Name</th>
</tr>
</thead>
<tbody>
@foreach ($alumnos as $alumno)
<tr>
<td>{{ $alumno->NAME }}</td>
</tr>
@endforeach
</tbody>
</table>
<div>
<div>
Show
<select>
<option value="5">5</option>
<option value="10" selected>10</option>
<option value="15">15</option>
</select>
entries
</div>
</div>
CodePudding user response:
Please check Laravel documentation on pagination . it addressed your challenge on creating pagination in blade.
CodePudding user response:
Yes, your idea is good. But you have to do more in controller and blade.
You can check here for simple example: http://novate.co.uk/allow-user-to-choose-pagination-length-via-dropdown-laravel/