Skip to content

Commit

Permalink
Sort foreign keys in with() method (#17730)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkis authored and taylorotwell committed Feb 3, 2017
1 parent a67aeeb commit 0ba0887
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ protected function getEagerModelKeys(array $models)
return [$this->relationHasIncrementingId() ? 0 : null];
}

sort($keys);

return array_values(array_unique($keys));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Relations/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected function getKeys(array $models, $key = null)
{
return collect($models)->map(function ($value) use ($key) {
return $key ? $value->getAttribute($key) : $value->getKey();
})->values()->unique()->all();
})->values()->unique()->sort()->all();
}

/**
Expand Down

0 comments on commit 0ba0887

Please sign in to comment.