Eloquent/Collection: Call to a member function getKey() on string #43016
Unanswered
LastDragon-ru
asked this question in
Q&A
Replies: 1 comment
-
|
Still the case in Laravel 12. Ran into this issue with mapWithKeys and I agree with you it should map into a base collection in the empty case, otherwise behaviour is different based on whether a query returned results or not. Also if the collection is empty I don't expect the Eloquent specific methods would be that useful. However this would be a BC break for that reason I don't expect it to change, workaround is to call |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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
Beta Was this translation helpful? Give feedback.
All reactions