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?
EDIT: Thanks for your help @enrollment!! This is how code is right now. I think it's close to work and I like very much this code, can you help me to finish it?
web.php
Route::resource('alumnos', AlumnosController::class);
Route::get('/alumnos?{paginateValue}', [AlumnosController::class, 'showPaginated'])->name('alumnos');
Route::post('/alumnos', [AlumnosController::class, 'update'])->name('update.paginateValue');
AlumnosController.php
public function index(Request $request)
{
$alumnos = Alumnos::select('ALU_ID', 'ALU_NOMBRE', 'ALU_APELLIDO1', 'ALU_APELLIDO2')
->orderBy('ALU_ID', 'desc')
->paginate(10);
return view ('alumnos.alumnos', compact('alumnos'));
}
index.blade.php
<table class="datatable">
<thead>
<tr>
<th>ID</th>
<th>Nombre y apellidos</th>
</tr>
</thead>
<tbody>
@foreach ($alumnos as $alumno)
<tr>
<td>{{ $alumno->ALU_ID ?? '(Sin ID)' }}</td>
<td>{{ $alumno->ALU_NOMBRE ?? '(Sin Nombre)' }} {{ $alumno->ALU_APELLIDO1 ?? '(Sin Apellido 1)' }} {{ $alumno->ALU_APELLIDO2 ?? '(Sin Apellido 2)' }}</td>
</tr>
@endforeach
</tbody>
</table>
<div class="footer-tools">
@isset($paginateValue)
<div class="pages">
{{$alumnos->links()}}
</div>
@endisset
<form action="{{route('update.paginateValue')}}" method="POST">
@csrf
<select name="select" id="select" onchange="this.form.submit()">
<option>Filter by quantity</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>
</form>
</div>