Password registration with Hash in Laravel bank

Asked

Viewed 1,213 times

1

Look guys I’m not able to register the password with the hash in the bank, I can register all data but the password is not encrypted

public function CadastroSalvar (Request $request) {

   \App\Usuario::create($request->all(),[
       $request = Input::get('nome'),
       $request = Input::get('email'),
       $request = Input::get(Hash::make('senha')),
       $request = Input::get('telefone'),
       $request = Input::get('data_nascimento'),
       $request = Input::get('rg'),
       $request = Input::get('funcao'),
   ])->save();    


    return redirect()->route('UsuarioCadastro');
}  

1 answer

2


Your code is wrong and you have invalid calls:

When create is used, a array with the information that is configured in $fillable that model and also to generate the hash of the password was using the inverted code, example of what would be the correct:

public function CadastroSalvar (Request $request) 
{

   $data = $request->all();
   $data['senha'] = \Hash::make($data['senha']); // ou bcrypt($data['senha']);

   $usuario = \App\Usuario::create($data);

   return redirect()->route('UsuarioCadastro');

} 

References:

  • 1

    vlw man, Thank you worked perfectly, thanks for the tip ^^

Browser other questions tagged

You are not signed in. Login or sign up in order to post.