jenssegers/Laravel-MongoDB — pull request #138 by alexandre-butynski (2014-02-28 15:29:34+00:00)
Title: Work on embeds-many relationship

More work on embedded relationships. Again, it come from our projects sources used in production and, again, I'm really open about review on API syntax, implementation, naming...

What is done :

- Deal with edge cases like `'_id' => ''`
- Any method of `Collection` can be applied on an embeds-many relationship. This methods are executed when `getResults` is called. With that we can have similar features than in a classic one-to-many relationship (where any method of `Eloquent\Builder` can be applied) :

```PHP
public function addresses() { return $this->hasMany('Address')->orderBy('city'); }
public function addresses() { return $this->embedsMany('Address')->sortBy('city'); }
```

- To prevent refactoring issues from classic has-many, the method `get()` is implemented (just a shorthand for `getResults()`).
- We can easily delete embedded items (with or without persistance)
- The parent model is automatically saved in the embedded model (I think it could have conflicts here but it is really convenient !)

Look at test cases for more details.