Register password with Hash at Laravel bank

1

Hello everyone, I am not able to register the password with the hash in the database, I can register all the 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');
}  
    
asked by anonymous 25.01.2018 / 17:43

1 answer

2

Your code is wrong and has invalid calls:

When using create, a array is required with the information that is set in $fillable of that model and also to generate hash of the password was using the inverted code, example of what would be 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:

25.01.2018 / 18:15