Skip to content

Commit

Permalink
cast to string if key type is string
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 24, 2020
1 parent 5813b00 commit c3f44c7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Illuminate/Database/Eloquent/Relations/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,11 @@ protected function getResultsByType($type)
*/
protected function gatherKeysByType($type, $keyType)
{
if ($keyType === 'string') {
return array_map(function ($modelId) {
return (string) $modelId;
}, array_keys($this->dictionary[$type]));
}

return array_keys($this->dictionary[$type]);
return $keyType !== 'string'
? array_keys($this->dictionary[$type])
: array_map(function ($modelId) {
return (string) $modelId;
}, array_keys($this->dictionary[$type]));
}

/**
Expand Down

0 comments on commit c3f44c7

Please sign in to comment.