From eebb4961b1e41a6d56234e4e9182d0889fc5826b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 17 Jun 2024 09:06:28 -0500 Subject: [PATCH] Update src/Illuminate/Database/Eloquent/Relations/Relation.php Co-authored-by: Caleb White --- src/Illuminate/Database/Eloquent/Relations/Relation.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Relations/Relation.php b/src/Illuminate/Database/Eloquent/Relations/Relation.php index 0eb6ed8c3296..cba4ca2afed0 100755 --- a/src/Illuminate/Database/Eloquent/Relations/Relation.php +++ b/src/Illuminate/Database/Eloquent/Relations/Relation.php @@ -509,13 +509,7 @@ public static function getMorphedModel($alias) */ public static function getMorphAlias(string $className) { - foreach (static::$morphMap as $alias => $morphedClass) { - if ($morphedClass === $className) { - return $alias; - } - } - - return null; + return array_flip(static::$morphMap)[$className] ?? null; } /**