0
In a contact management system, I have a list of items which have a checkbox each (gmail style) so I can select them and use some action related to the selected ones. What is the best way to save these selected items to each accessed page?
One of the Controllers listing the items:
$request = DB::table('contatos')
->select('*')
->paginate(15);
return view('list')
->with('request', $request);
And the View:
<table>
<tr>
<th><input type="checkbox" id="seleciona_todos" /></th>
<th>Nome</th>
<th>E-mail</th>
</tr>
@foreach($r as $p)
<tr>
<td><input type="checkbox" value="{{ $p->id }}" /></td>
<td>{{ $p->nome }}</td>
<td>{{ $p->email }}</td>
</tr>
@endforeach
</table>
{!! $r->appends(Input::except('page'))->links(); !!}
- Has pagination
- I use the Laravel
- You will have other admin user accounts moving at the same time
I’ve thought about doing an ajax for a php file that saves and deletes items from an array in a session or even using a table in the database to record the currently selected items (but there will be other users stirring at the moment and I don’t think this would work). What’s the best way to solve this?
If you want to see the modifications in real-time Pusher and Laravel echo
– PaulinhoCaP
you can do so in your input:
<input type="checkbox" name="selecionados[]" value="{{$p->id}}">
and capture the array: $dataForm = $request->all(); dd($dataForm['selected']), thedd()
must return avar_dump
of the Laravel.– Ivan Ferrer