Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.3' into 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 3, 2016
2 parents eac8dc4 + 660849b commit 6b5705d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/Illuminate/Auth/Passwords/PasswordBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ public function validator(Closure $callback)
*/
public function validateNewPassword(array $credentials)
{
list($password, $confirm) = [
$credentials['password'],
$credentials['password_confirmation'],
];

if (isset($this->passwordValidator)) {
list($password, $confirm) = [
$credentials['password'],
$credentials['password_confirmation'],
];

return call_user_func(
$this->passwordValidator, $credentials) && $password === $confirm;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ public function bind($abstract, $concrete = null, $shared = false)
*/
protected function getClosure($abstract, $concrete)
{
return function ($c, $parameters = []) use ($abstract, $concrete) {
return function ($container, $parameters = []) use ($abstract, $concrete) {
$method = ($abstract == $concrete) ? 'build' : 'make';

return $c->$method($concrete, $parameters);
return $container->$method($concrete, $parameters);
};
}

Expand Down
24 changes: 21 additions & 3 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -3067,13 +3067,31 @@ public function is(Model $model)
}

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateNotificationsTable extends Migration
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->string('id')->primary();
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Support/Pluralizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Pluralizer
'emoji',
'equipment',
'fish',
'furniture',
'gold',
'information',
'knowledge',
Expand All @@ -41,6 +42,7 @@ class Pluralizer
'species',
'swine',
'traffic',
'wheat',
];

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ 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

0 comments on commit 6b5705d

Please sign in to comment.