*/ protected $fillable = [ 'user_id', 'code' ]; /** * Set the code attribute and automatically hash the code. * * @param string $value * @return void */ public function setCodeAttribute($value) { $this->attributes['code'] = Hash::make($value); } /** * Verify the given code against the stored hashed code. * * @param string $value * @return bool */ public function verify($value) { return Hash::check($value, $this->code); } }