The problem that occurs is the following I have a table with checkbox, I click on several to be sent with a file that you select, by clicking on the button to upload file to each user that you select in the view . This is the controller's method. which takes the data to the database and saves it but I do not know how I could do it one by one and I've been stuck on that.
public function store(Request $request)
{
if($request->hasFile('link')){
$cliente = $request->input('cliente');
$proyecto = $request->input('proyecto');
$calendario = $request->input('Calendario');
$fecha = $request->input('fecha');
$anno = $request->input('anno');
$document = $request->file('link');
$file_name = time().$document->getClientOriginalName();
$request->file('link')->storeAs('boletines', $file_name);
}
$file = new File();
$file->cliente = $cliente;
$file->proyecto = $proyecto;
$file->fecha = $fecha;
$file->anno = $anno;
$file->calendario = $calendario;
$file->name = $document->getClientOriginalName();
$file->link = $file_name;
$lista = array();
$add = array($file);
foreach ($add as $clave) {
$array = explode(',',$clave);
$file->save($array);
}
Session::flash('Exito','Boletin Guardado');
return Redirect::to('/Admin/file/create');
}
The view would be this customers
<div class="busqueda" id="busqueda-clientes">
<div class="buscador">
<input type="search" title="Escriba Para Buscar" id="buscar-clientes" placeholder="Buscar">
</div>
</div>
<div class="scroll" style="height:90%;overflow: auto;">
<table class="table table-bordered table-striped" id="dtDynamicVerticalScroll">
<tbody id="dtDynamicVerticalScroll">
<tr>
<th><input type="checkbox" onclick="toggle(this)" style=" left:" /></th> <!--check que checked todos-->
<th>Seleccionar todos</th>
</tr>
@foreach($clients as $client)
<td id="{{$client->id}}" title="{{$client->nombre}}" ><input id="client{{$client->id}}" type="checkbox" class="valor trigger" name="checkit" value="{{$client->id}}" data-id="{{$client->id}}" id="{{$client->id}}">
</td>
<td>
<b class="maxi" data-id="{{$client->id}}" id="{{$client->id}}" >{{$client->nombre}}</b>
@foreach($proyecto as $pro)
@if($client->id == $pro->cliente)
<div id="tablaescondida" class="letableu{{$client->id}}" style="display: none">
<div class="content-table">
<table class="table table-bordered table-striped" id="dtDynamicVerticalScroll">
<tbody id="dtDynamicVerticalScroll">
<tr>
<td>
<input type="checkbox" class="g" name="valorproducto" value="{{$pro->id}}" id="pro{{$pro->id}}">
</td>
<td><b>{{$pro->nombre}}</b></td>
</tr>
</tbody>
</table>
</div>
</div>
@endif
@endforeach
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
She is placed by clicking on the check in a
<input type="text" name="fecha" hidden="hidden" id="textofecha" >
<input type="text" name="anno" hidden="hidden" id="textoann" placeholder="anno">
<textarea type="text" rows="2" hidden="hidden" id="textosid" name="cliente[]" ></textarea>
<textarea type="text" rows="2" hidden="hidden" id="textproyecto" name="proyecto[]"></textarea>
What I have not been able to achieve is the following when clicking on the checks, let's say I have users 1, 2, 3, 4 with projects 2, 1, 5, 6 for example and in and upload a file what It happens that I occupy that it is of the following way, let's say that in the table of the database it has to go this way when it selects the 4 users This is the table and that way I would have to stay **
- row 1 client 1 project 2, file 1 row 2 client 2 project 1, file 1 row 3 client 3 project 5, file 1 row 4 client 4 project 6, file 1
**