Variable undifined when trying to insert values from 1 form into 2 tables with RegisterControlller in Laravel 8

  laravel, php

I’m trying to use the registerController to insert data into 2 tables of SQL, the Users table of Laravel and one table called personas that is associated to the Persona Model.

$datos= ['nombre' => $data['name'],'apellido' => $data['surname'],'cedula' => $data['cedula'],'email' => $datos['email'],
    'telefono' =>$datos['telefono'],'direccion' =>$datos['direccion'],'ciudadResi' =>$datos['ciudadResi'],'genero' =>$datos['genero'],]; 

        'nombre' => $datos['nombre'],
        'apellido' => $datos['apellido'],
        'cedula' => $datos['cedula'],
        'email' => $datos['email'],
        'telefono' =>$datos['telefono'],
        'direccion' =>$datos['direccion'],
        'ciudadResi' =>$datos['ciudadResi'],
        'fechaNacimiento' =>'1998-03-05',
        'genero' =>$datos['genero'],
        'estado'=> '1',
        'name' => 'clienteUser',
        'surname' => $data['surname'],
        'email' => $data['email'],
        'nick' => $data['nick'],
        'password' => Hash::make($data['password']),
        'role' => 'cliente'

That is the code in the RegisterController that is generated by auth of Laravel, what I’m trying to do is get the $data from the form in register.blade because I don’t need the updated_at and created_at that $data have I want to store the values I want to insert in the persona table in the $datos array, insert them into the table and insert the values I need for User form Data.

When I try to do that it says that $datos is undefined. What should I need to solve the problem? English is not my main language so I would appreciate if explanations are easy.

Source: Laravel

Leave a Reply