Skip to content

Commit c9e0739

Browse files
committed
Fix morphTo
1 parent a1769cf commit c9e0739

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/Jenssegers/Mongodb/Eloquent/HybridRelations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function morphTo($name = null, $type = null, $id = null)
185185
// use that to get both the class and foreign key that will be utilized.
186186
if (is_null($name))
187187
{
188-
list($current, $caller) = debug_backtrace(false, 2);
188+
list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
189189

190190
$name = Str::snake($caller['function']);
191191
}

src/Jenssegers/Mongodb/Relations/MorphTo.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,23 @@ public function addConstraints()
1818
}
1919
}
2020

21+
/**
22+
* Get all of the relation results for a type.
23+
*
24+
* @param string $type
25+
* @return \Illuminate\Database\Eloquent\Collection
26+
*/
27+
protected function getResultsByType($type)
28+
{
29+
$instance = $this->createModelByType($type);
30+
31+
$key = $instance->getKeyName();
32+
33+
$query = $instance->newQuery();
34+
35+
$query = $this->useWithTrashed($query);
36+
37+
return $query->whereIn($key, $this->gatherKeysByType($type)->all())->get();
38+
}
39+
2140
}

test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php require 'vendor/autoload.php';

0 commit comments

Comments
 (0)