Add Notes to Students in bulk laravel

1

Hi Good I am creating a system of educational administration, it turns out that I have created the module to enter notes to the students

the problem is that the way to enter the notes is one by one and now I need to enter the notes in a massive way (to all students of a subject). Someone could help me please, I'm just starting with laravel and I know the basics. Any guide or tutorial that is helpful. Thanks in advance.

I'm used to inserting data like you see in the image one by one, the classic crud and its table in which in each row you have data and in the end Edit or Delete operations that are easy to perform because in that field you receive the $ id.

What I need now is to insert several data at the same time to many users who in this case are students, something like this:

driver to add rating to one

public function agregarCalificacion($id, $idasi)
{   
    $alumno = Alumno::find($id);
    $asignatura = Asignatura::find($idasi);
    return view('agregar/calificacion')->with('alumno',$alumno)->with('asignatura',$asignatura);
}
    
asked by Edgardo Escobar 03.04.2017 в 03:09
source

2 answers

1

It seems to be relatively simple solution to your problem, you can use arrays generated in the form, whose indexes would be similar to what you show in the example table, something like this:

@foreach ($alumnos as $alumno)

    <tr>
      <td>{{ $alumno->nombre }}</td>

      @foreach ($notas as $nota)

        <td>{{ Form::text('notas[' . $alumno->id . '][' . $nota->id . ']') }}</td>

      @endforeach

    </tr>

@endforeach

At the time of receiving the form you have a multidimensional arrangement in $request->notas , there you can reference each student and obtain the corresponding values.

    
answered by 04.04.2017 в 16:58
0

You can insert multiple elements in the table using a code like the following:

DB::table('users')->insert([
    ['email' => '[email protected]', 'votes' => 0],
    ['email' => '[email protected]', 'votes' => 0]
]);

In the documentation Laravel, Inserting multiple elements

    
answered by 03.04.2017 в 06:20