From d21dcb6d1e3a1aa464b7434bde5e0fa80fd19a44 Mon Sep 17 00:00:00 2001 From: Loris Lunardi Date: Mon, 20 Jan 2020 14:04:52 +0800 Subject: [PATCH] Prevent ambiguous column error adding from table prefix --- .../Database/Eloquent/Concerns/QueriesRelationships.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php index dd8721bc4fff..cedfc9b7f4cc 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php +++ b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php @@ -222,7 +222,7 @@ public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boole }; } - $query->where($relation->getMorphType(), '=', (new $type)->getMorphClass()) + $query->where($this->query->from.'.'.$relation->getMorphType(), '=', (new $type)->getMorphClass()) ->whereHas($belongsTo, $callback, $operator, $count); }); }