Commit c9e0739d authored by Jens Segers's avatar Jens Segers

Fix morphTo

parent a1769cfb
...@@ -185,7 +185,7 @@ trait HybridRelations { ...@@ -185,7 +185,7 @@ trait HybridRelations {
// use that to get both the class and foreign key that will be utilized. // use that to get both the class and foreign key that will be utilized.
if (is_null($name)) if (is_null($name))
{ {
list($current, $caller) = debug_backtrace(false, 2); list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$name = Str::snake($caller['function']); $name = Str::snake($caller['function']);
} }
......
...@@ -18,4 +18,23 @@ class MorphTo extends EloquentMorphTo { ...@@ -18,4 +18,23 @@ class MorphTo extends EloquentMorphTo {
} }
} }
/**
* Get all of the relation results for a type.
*
* @param string $type
* @return \Illuminate\Database\Eloquent\Collection
*/
protected function getResultsByType($type)
{
$instance = $this->createModelByType($type);
$key = $instance->getKeyName();
$query = $instance->newQuery();
$query = $this->useWithTrashed($query);
return $query->whereIn($key, $this->gatherKeysByType($type)->all())->get();
}
} }
<?php require 'vendor/autoload.php';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment