Skip to content
Merged
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
11 changes: 9 additions & 2 deletions src/Illuminate/Database/Eloquent/Relations/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,25 @@ protected function getResultsByType($type)
$whereIn = $this->whereInMethod($instance, $ownerKey);

return $query->{$whereIn}(
$instance->getTable().'.'.$ownerKey, $this->gatherKeysByType($type)
$instance->getTable().'.'.$ownerKey, $this->gatherKeysByType($type, $instance->getKeyType())
)->get();
}

/**
* Gather all of the foreign keys for a given type.
*
* @param string $type
* @param string $keyType
* @return array
*/
protected function gatherKeysByType($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]);
}

Expand Down