From ab05609a5aa291a6f91b38dbb2800e3ac80a4f97 Mon Sep 17 00:00:00 2001 From: "Connor S. Parks" Date: Mon, 24 Apr 2017 18:59:12 +0100 Subject: [PATCH] [5.4] Null Morph Map ErrorException (#18921) * [5.4] Null Morph Map ErrorException Currently, if you call `getActualClassNameForMorph` without the morph map set, it will through an error because `Relation::morphMap()` returns `null` instead of (what I would expect) `[]`. Is this expected behaviour? If so, why is this expected behaviour? * Create HasRelationships.php --- src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php b/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php index 038740b9fe81..703a3fccf3b1 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php @@ -192,7 +192,7 @@ protected function morphInstanceTo($target, $name, $type, $id) */ public static function getActualClassNameForMorph($class) { - return Arr::get(Relation::morphMap(), $class, $class); + return Arr::get(Relation::morphMap() ?: [], $class, $class); } /**