RSS Feed/News AbstractCollection->pluck() should always return collection when $collectionOnEmpty=true

Status
Not open for further replies.

ENXF NET

Administrator
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P.S Member
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Nov 13, 2018
Messages
23,543
Points
823

Reputation:

I just had a case where I did $entity->TagRelations->pluckNamed('Tag', 'tag_id')->toArray().

In rare circumstances I would get a "could not call toArray() on array" error.

This was puzzling as the call uses pluck() in the implementation and because Tag is uppercase, it will have $collectionOnEmpty=true so it should return a collection. That's the name of the variable.

In rare circumstances this would NOT return a collection because the Tag pointed at...

Read more

Continue reading...
 
Status
Not open for further replies.
Top