When calling $collection->intersect(null) on an Eloquent Collection the whole $collection is returned. I would expect an error or, possibly, an empty collection to be returned. Note that doing the same thing on a regular base collection returns an empty collection.
We had this happen, causing silent errors (we called intersect with a nonexistant relation as argument, which gets returned as null).
Assuming you have an Eloquent Collection $eloquentCollection that isn't empty, simply call
$eloquentCollection->intersect(null);
The entire collection will be returned. Expected behavior would be an error or, possibly, an empty collection. Again, note that doing the same thing on a base collection returns an empty collection.
Tested this and confirmed. This indeed seems like unwanted behavior. Welcoming prs for this.
Hmm, am I missing something here? $collection->intersect(null) returns an empty collection.
@ahinkle this bug only occurs on Eloquent collection