I want to be able to store multiple array values in one save operation. Is this possible?
I have a dynamic table that produces the following array:
array:5 [▼
"_token" => "cNvFpF7e7fVl0vDxPcCOlbH0eUadXIWaokwH7z3F"
5 => array:9 [▼
0 => "1"
1 => "1"
2 => "0"
3 => "2"
4 => "0"
5 => "3"
6 => "0"
7 => "0"
8 => "0"
]
4 => array:9 [▼
0 => "1"
1 => "0"
2 => "0"
3 => "0"
4 => "0"
5 => "0"
6 => "0"
7 => "0"
8 => "0"
]
6 => array:9 [▶]
"save" => null
]
where 4 =>, 5 =>, and 6 => represent user_ids and the arrays, their respective scores. I am not sure how I would go about iterating through the multiple arrays to store the data.
The DB table structure is id, user_id, game_id, col-1, col-2, etc
Hopefully, this is clear enough but if yo need more info, please let me know. Thanks
Here is the table code: This is the code I have for my table :
@foreach($players as $p)
<tr class="">
<td class="h2 align-middle">
{{ $players->get($loop->index)->first_name }}
<input type="text" name="user_id" value="{{ $p->id }}">
</td>
@foreach($innings as $inning)
<td class="p-1">
<div class="form-group_{{$p->id}} input-group p-1 h4">
<select class="custom-select custom-select-lg py-0 prc" id="" name="player[{{$p->id}}]">
<option class="" value="0">0</option>
@foreach($scores as $score)
<option name="score[]" value="{{ $score }}">{{ $score }}</option>
@endforeach
</select>
</div>
</td>
@endforeach
<td>
<div class="h1 text text-center font-weight-bold pt-2">
<output id="result_{{$p->id}}"></output>
</div>
</td>
</tr>
@endforeach