laravel/framework — pull request #3805 by ThomasRuiz (2014-03-06 11:25:09+00:00)
Title: Fix attribute access when mixing mutators and cases

Related to https://github.com/laravel/framework/issues/316

I found a bug when mixing mutators and cases. If the key's case in the attributes array differ from the one used to access the model's attribute (e.g `$model->myAttribute`), the key will not be found.

Below the test that checks it with the corresponding model :

```php
public function testAttributeAnyCaseAccess()
{
$model = new MyModel;

$model->anyCase = 'foo';
$this->assertArrayHasKey('any_case', $model->getAttributes());
$this->assertEquals('foo', $model->any_case);
$this->assertEquals('foo', $model->anyCase);

$model->any_case = 'bar';
$this->assertEquals('bar', $model->any_case);
$this->assertEquals('bar', $model->anyCase);
}

class MyModel extends Eloquent {
protected $table = 'test_model';

public function getAnyCaseAttribute($value)
{
return $value;
}

public function setAnyCaseAttribute($value)
{
$this->attributes['any_case'] = $value;
}
}
```

Which fails at the third assert.

```
Failed asserting that null matches expected 'foo'.

app/tests/ExampleTest.php:12
```

This commit adds a simple fix to this issue,