Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2537,6 +2537,7 @@ public function hasGetMutator($key)
public function getMutatorMethod($key)
{
$mutators = static::$mutatorCache[$this->klass];
$key = snake_case($key);

return isset($mutators[$key]) ? $mutators[$key] : null;
}
Expand Down Expand Up @@ -3171,4 +3172,4 @@ public function __wakeup()
$this->bootIfNotBooted();
}

}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GrahamCampbell sorry, I'll try to avoid this in the future :)

14 changes: 12 additions & 2 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,10 @@ public function testAppendingOfAttributes()
{
$model = new EloquentModelAppendsStub;
$this->assertEquals('admin', $model->is_admin);
$this->assertEquals('camelCased', $model->camelCased);
$this->assertEquals('StudlyCased', $model->StudlyCased);

$model->setHidden(['is_admin']);
$model->setHidden(['is_admin', 'camelCased', 'StudlyCased']);
$this->assertEquals([], $model->toArray());

$model->setVisible([]);
Expand Down Expand Up @@ -1133,9 +1135,17 @@ public static function isBooted()
}

class EloquentModelAppendsStub extends Illuminate\Database\Eloquent\Model {
protected $appends = array('is_admin');
protected $appends = array('is_admin', 'camelCased', 'StudlyCased');
public function getIsAdminAttribute()
{
return 'admin';
}
public function getCamelCasedAttribute()
{
return 'camelCased';
}
public function getStudlyCasedAttribute()
{
return 'StudlyCased';
}
}