laravel/framework — pull request #3637 by rporrasluc (2014-02-21 08:43:29+00:00)
Title: Proposal for mutating data when updating using Eloquent Builder

There is a issue when updating a table calling the method update of Eloquent/Builder instead of the Eloquent/Model method. That is, using your example:

$affectedRows = User::where('votes', '>', 100)->update(array('status' => 2));

If we have the following mutator:

public function setStatusAttribute($value)
{
$this->attributes['status'] = $value;
if ($value == 2)
{
$this->attributes['message'] = 'You're good!'
}
else
{
$this->attributes['message'] = 'You're almost not voted!'
}

This mutator is not called when updating the model as I have just indicate. Actually, the update must be done getting the collection of users and iterating through them to get each model and update it individually. This produces more connections to the database.

The proposal is not debugged, but shows the issue found.