jenssegers/Laravel-MongoDB — pull request #137 by alexandre-butynski (2014-02-27 10:17:16+00:00)
Title: [Proposal] Add embedsMany relationship to Eloquent Model

This pull request come from code that we are using in our Laravel projects. Because this package is not made to rewrite Eloquent, MongoDB specificities are generally not yet implemented. But the main difference, for web development, with a standard SQL driver is the ability to *embed* documents inside other ones.

We can do that with this package but only with *manual* data manipulations or quite a lot of custom code. That's why I have wrote an EmbedsMany class in order to deal with this specificity with a high level of abstraction.

In order to keep the spirit of this package, I tried to keep it as close as I can of Eloquent syntax. For example, the three lines below are exactly the same for a `hasMany` relationship than for a `embedsMany` relationship :

```PHP
$address = new Address(array('city' => 'Paris'));
$user->addresses()->save($address);
$addresses = $user->addresses;
```
I also add several others methods that are basically shorthand to do the same things with raw data, with array of related models and without persistence. You can find that in the test cases.

The main difference from SQL Eloquent relationship is that this relationship is not, in fact, a query but directly an array of data. That's why I had to wrote an other relation parent class : `EmbeddedRelation`.

I just worked on adding an embedded model and retrieve the list of this models. More work could be done (method `remove` or `delete`, test edge cases...) but I want your opinion about that before.

What do you think about the idea, if we keep it simple and close to Eloquent syntax ? What do you think about the implementation (method naming, number of shorthand, architecture...) ?