Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[5.3] Allow key arguments to model getAttributes" #15813

Merged
merged 1 commit into from
Oct 7, 2016
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
24 changes: 3 additions & 21 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -3067,31 +3067,13 @@ public function is(Model $model)
}

/**
* Get a selection of the current attributes on the model.
*
* @param array $keys
* Get all of the current attributes on the model.
*
* @return array
*/
public function getAttributes($keys = [])
public function getAttributes()
{
if ($keys === []) {
return $this->attributes;
}

$keys = is_array($keys) ? $keys : func_get_args();

$result = [];

foreach ($keys as $key) {
$value = $this->getAttribute($key);

if (! is_null($value)) {
$result[$key] = $value;
}
}

return $result;
return $this->attributes;
}

/**
Expand Down
12 changes: 0 additions & 12 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ public function testAttributeManipulation()
$this->assertEquals(json_encode(['name' => 'taylor']), $attributes['list_items']);
}

public function testGetMultipleAttributes()
{
$model = new EloquentModelStub(['name' => 'taylor', 'framework' => 'laravel', 'foo' => 'bar']);

$this->assertEquals(['name' => 'taylor', 'foo' => 'bar'], $model->getAttributes('name', 'foo'));
$this->assertEquals(['name' => 'taylor', 'foo' => 'bar'], $model->getAttributes(['name', 'foo']));
$this->assertEquals(['name' => 'taylor'], $model->getAttributes('name'));
$this->assertEquals(['name' => 'taylor'], $model->getAttributes(['name']));

$this->assertEquals(['name' => 'taylor'], $model->getAttributes(['name', 'doesntexist']));
}

public function testDirtyAttributes()
{
$model = new EloquentModelStub(['foo' => '1', 'bar' => 2, 'baz' => 3]);
Expand Down