Reputation: 295
I am trying to convert plain text password in database to encrypted password but not is not saving in database a encrypted password ?
How can i do this ?
please see this user table https://ibb.co/7SKTbqW
controller
public function registeraction(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required',
'password' => 'required|alphaNum|min:6',
]);
$name = $request->get('name');
$email = $request->get('email');
$password = bcrypt($request->get('password'));
$user = User::create(request(['name', 'email','password']));
$user->setRememberToken(Str::random(60));
$user->save();
if ($user) {
// Authentication passed...
return redirect()->to('/');
}
}
Upvotes: 1
Views: 125
Reputation: 17388
In your code, you are retrieving the password
value from the $request
and modifying the value.
$password = bcrypt($request->get('password'));
However, when you create the user, you're retrieving the original unmodified password
value from the $request
again.
$user = User::create(request(['name', 'email','password']));
Instead, this line should read:
$user = User::create(compact('name', 'email','password'));
Upvotes: 1
Reputation: 6005
Try Hash:make
use Illuminate\Support\Facades\Hash;
$password = Hash::make($request->get('password'));
Upvotes: 1