0
When performing a request
I’m getting undefined index
.
The code in question:
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'telefone' => $data['telefone'],
'usuario_anjo' => $data['usuario_anjo'],
'password' => bcrypt($data['password']),
]);
}
My class:
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'password_confirmation', 'telefone', 'usuario_anjo'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token', 'password_confirmation'
];
}
My request:
email: "[email protected]"
name: "teste"
password: "teste"
telefone: "(16)98182-4833"
usuario_anjo: 0
the error in question:
message: "Undefined index: usuario_anjo"
My column in the bd
is defined as int
.
Could someone please tell me why this mistake?
Before calling the create function uses this here: echo '<pre>'; print_r( $data ); die; E put here the return.
– Kayo Bruno