Collection merge does not work without an overridden getKey() method
Open
- Dominant language
- PHP
- Stars
- 394
- Forks
- 59
- PR merge metrics
- No merged PRs in 30d
Description
I realised that if you want to merge two collections like this:
```
$collection1->merge($collection2)
```
You will get an exception saying that you haven't implemented a **getKey()** method. After som digging around, I found that, as long as you implement this method on the model and return something unique for each model instance, the merge will work.
I guess my tip is that the getKey() method is implemented in the **Model.php** file and that the developers using this package can provide an **id** attribute which is unique for all model instances :)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.