The
bcrypt
function hashes the given value using Bcrypt. You may use this function as an alternative to the Hash
facade:<?php $password = bcrypt('my-secret-password');
<?php AuthenticationTestUser::create([
'username' => 'username',
'email' => 'email',
'password' => bcrypt('password'),
'is_active' => true,
]);
}
<?php AuthenticationTestUser::create([
'username' => 'username2',
'email' => 'email2',
'password' => bcrypt('password'),
'is_active' => false,
]);
<?php $user = AuthenticationTestUser::create([
'username' => 'username2',
'email' => 'email2',
'password' => bcrypt('password'),
'remember_token' => $token = Str::random(),
'is_active' => false,
]);
<?php User::forceCreate([
'username' => 'taylorotwell',
'email' => 'taylorotwell@laravel.com',
'password' => bcrypt('password'),
'is_active' => true,
]);
}
<?php $this->assertNull($user->password());
$user->data(['password_hash' => bcrypt('secret')]);
$this->assertNotNull($user->password());
$this->assertTrue(Hash::check('secret', $user->password()));