From 87909088379d25795db7fe7c2ed5bb8fe2ed8d81 Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Sun, 6 Jan 2019 18:57:30 +0100 Subject: [PATCH] Simplify loadMorph() --- src/Illuminate/Database/Eloquent/Collection.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Collection.php b/src/Illuminate/Database/Eloquent/Collection.php index 03e830e10c5a..44690fb1cf35 100755 --- a/src/Illuminate/Database/Eloquent/Collection.php +++ b/src/Illuminate/Database/Eloquent/Collection.php @@ -182,11 +182,8 @@ public function loadMorph($relation, $relations) ->groupBy(function ($model) { return get_class($model); }) - ->filter(function ($models, $className) use ($relations) { - return Arr::has($relations, $className); - }) ->each(function ($models, $className) use ($relations) { - static::make($models)->load($relations[$className]); + static::make($models)->load($relations[$className] ?? []); }); return $this;