illuminate/database — pull request #42 by adrianmacneil (2012-11-09 04:54:39+00:00)
Title: Add support for calculated attributes which aren't stored in the database

This is my suggested patch for #40. I've added support for mutator methods which don't store anything in their database column.

New setter behavior:

public function setPassword($value)
{
$this->attributes['password_hash'] = md5($value);
}

Because this setter doesn't return anything, `$this->attributes` is not updated (and therefore it does not attempt to store `password` in the database). Previously, `$this->attributes` was always updated, even if the setter returned `null`. If the setter returns a value, `$this->attributes` is updated as normal.

New getter behavior:

public function getFullName()
{
return $this->first_name.' '.$this->last_name;
}

This value can now be accessed using `$model->full_name` (previously, `$model->full_name` would return `null` because `full_name` was not a key on `$this->attributes`).