I have a question, I would like to know if it is possible to save the checkboxes that I have in one detail (so many of those selected and not selected), for example, I have an attendance detail, where it shows me all the people that are registered, and I keep that in my database, but my question goes further, because I only save the ones I have selected and I can not save what I did not select, the selected ones I entered a 1 and those who are not with a 2.
My base saves the following fields:
-
id
: what is the id of my assistance. -
alumno_id
: what is the student's id -
asitencia
: 1: for whom is this, 2 for whom I did not select
I have the input in detail:
<input type="checkbox" name="asistencia[]" id="asistencia[]" value="{{$al->id}}">
and my code that stores the data
if($data=$request->asistencia){
foreach ($data as $asis=>$valor){
$asis= New AsistenciaAlumnos();
$asis->alumno_id = $valor;
if(isset($request->asistencia)) {
$asis->asistencia = 1;
}elseif(isset($request->asistencia)==NULL){
$asis->asistencia = 2;
}
$asis->save();
}
}
So far I can save the ones I have selected, but how can I save the ones I did not select?
Thanks