I am trying to show the selected users by means of a multiple selection , but only the last selected value is returned to me.
This is my code where I send the selected data in the view:
<div class="col-xs-4">
<div class="form-group">
<select name="operador[]" class="form-control select2" multiple="multiple" data-placeholder="Usuarios" style="width: 100%;">
@foreach($usuarios as $usuario)
<option value="{{$usuario->id}}">{{$usuario->name}}</option>
@endforeach
</select>
</div><!-- /.form-group -->
</div>
And in the Controller I do the tour in this way:
$idoperador = $request->input("operador");
$usuarios = [];
foreach ($idoperador as $usuario){
$usuarios= DB::table("users")
->where("id","=",$usuario)
->get();
}
return view('verificar.listaCorte', compact(['usuarios']));
This is the view where I receive the data from the controller
<th>Operador</th>
<th></th>
</tr>
@foreach($usuarios as $listado)
<tr>
<td>{{$listado->name}}</td>
</tr>
@endforeach
</table>
Thank you in advance.