Skip to content

Instantly share code, notes, and snippets.

@alexandrecruz
Created December 17, 2014 22:46
Show Gist options
  • Save alexandrecruz/17266ae9a4577aae6973 to your computer and use it in GitHub Desktop.
Save alexandrecruz/17266ae9a4577aae6973 to your computer and use it in GitHub Desktop.
class Usuario extends Eloquent {
/**
* Atributo - Magic Method
*
* Intercepta o setter do campo indicado em
* set(Campo)Attribute e executa o código
* antes de inserir o valor no objeto.
*
* @param string $value
* @return void
*/
public function setPasswordAttribute($value)
{
$this->attributes['password'] = Hash::make($value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment