I was trying to seed DB in Laravel with the given data, and i saw a snippet about HASH::make, mentioning it in The Model not in Seeder file..
TaskerTableSeeder.php
class TaskerTableSeeder extends Seeder{
public function run(){
Tasker::truncate();
Tasker::create([
'username'=>'junni',
'email'=> '[email protected]',
'password'=> 'Junaid'
]);
Tasker::create([
'username'=>'test',
'email'=> '[email protected]',
'password'=> 'Test'
]);
Tasker::create([
'username'=>'poni',
'email'=>'[email protected]',
'password'=>'Poni'
]);
}
}
and I Put that Code in my Tasker Model for Hash::make
class Tasker extends Eloquent{
public function setPasswordAttribute($value){
$this->attributes['password'] = Hash::make($value);
}
}
it is the way to make your password HASH encrypted, but i didn't find any information about setPasswordAttribute Function in Laravel Documentation.. and how many other attributes are there for which we can use such type of Functions.
The Laravel Hash facade provides secure Bcrypt hashing for storing user passwords. If you are using the AuthController controller that is included with your Laravel application, it will be take care of verifying the Bcrypt password against the un-hashed version provided by the user.
They are called Accessors and Mutators.
See Laravel documentation for more information.
They allow you to define behaviour when you set (mutator) or get (accessor) variables from your Eloquent models.
Another example would be
public function setUsernameAttribute($value){
$this->attributes['username'] = strtolower($value);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With