Reputation: 107
I have problem to my apps this input password hash.
$simpan['password']=Request::input('password');
how make hash in my code?
Upvotes: 0
Views: 151
Reputation: 3475
In Laravel we can handle it a very intelligent and efficient way by using Mutators in Model Class.
use Illuminate\Support\Facades\Hash;
class User extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
// Password hassing by default to all new users,
public function setPasswordAttribute($pass)
{
// here you can make any opration as you like
$this->attributes['password'] = Hash::make($pass);
}
}
now you don't have to do manually password hashing every time just store user in table by create or any other method
$created_user = User::create(request()->all());
Upvotes: 0
Reputation: 1928
You have two options
Call make method on Hash facade
Hash::make('string_here')
Or use global helper function bcrypt('string_here')
Example:
//Hash facade example
$simpan['password']= Hash::make(Request::input('password'));
//bcrypt global helper function
$simpan['password']= bcrypt(Request::input('password'));
Resource:
Upvotes: 1