The following code works fine when collection contains models but will fail if Collection is empty :
(new \Illuminate\Database\Eloquent\Collection())->map(fn() => 'converts item to string')->intersect(['a']);
Maybe map() it should return base collection if empty?
|
return $result->contains(function ($item) { |
|
return ! $item instanceof Model; |
|
}) ? $result->toBase() : $result; |
PS: Laravel v9.17.0
The following code works fine when collection contains models but will fail if
Collectionis empty :Maybe
map()it should return base collection if empty?framework/src/Illuminate/Database/Eloquent/Collection.php
Lines 361 to 363 in 95ce178
PS: Laravel v9.17.0