dimanche 21 août 2022

Array to string conversion in Laravel Checkbox

I am trying to insert the data to a one-to-many relationship table but when I insert I get the Array to string conversion error

Controller code

public function store(Request $request)
{
    //
    $data = Personas::create([
        'idSede' => $request->idSede,
        'idTpdoc' => $request->idTpdoc,
        'identificacion' => $request->identificacion,
        'nombre' => $request->nombre,
        'correo' => $request->correo,
        'telefono' => $request->telefono,
        'idTpasistente' => $request->idTpasistente,
        'empresa' => $request->empresa,
        'carrera' => $request->carrera,
    ]);

    $eventos = $request->eventos;

    foreach($eventos as $evento){
        $datos = detalle_persona_evento::create([
            'idPersonas' => $data->id,
            'idEventos' => $eventos,
        ]);
    }

    foreach([$request->correo] as $recipient){
        Mail::to($recipient)->send(new ProyectandoMail());
    }

}

Input code

<input type="checkbox" value="" id="E0" name="eventos[]">



Aucun commentaire:

Enregistrer un commentaire