Merging, diffing and intersecting Eloquent collections
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Edit: Merging, diffing and intersecting Eloquent collections is now included in Laravel by default! Please see the pull request here and issue discussion here for more information.
Keeping the original post here just for reference:
Extending on what I spoke about last time, and in relation to this laravel/framework
proposal, I've written some more methods for merging, diffing and intersecting Eloquent collections. Assuming these don't make it into the core, I've published them here with tests in case you'd like to use them in your own project (see my previous post for how to get Eloquent to load a custom collection object instead of the default).