diff --git a/README.md b/README.md index ce88b8144..58aae65c2 100644 --- a/README.md +++ b/README.md @@ -267,8 +267,6 @@ Supported relations are: - belongsTo - belongsToMany -*The belongsToMany relation will not use a pivot "table", but will push id's to a __related_ids__ attribute instead.* - Example: use Jenssegers\Mongodb\Model as Eloquent; @@ -295,6 +293,19 @@ And the inverse relation: } +The belongsToMany relation will not use a pivot "table", but will push id's to a __related_ids__ attribute instead. This makes the second parameter for the belongsToMany method useless. If you want to define custom keys for your relation, set it to `null`: + + use Jenssegers\Mongodb\Model as Eloquent; + + class User extends Eloquent { + + public function groups() + { + return $this->belongsToMany('Group', null, 'users', 'groups'); + } + + } + Other relations are not yet supported, but may be added in the future. Read more about these relations on http://four.laravel.com/docs/eloquent#relationships ### Raw Expressions diff --git a/tests/models/Group.php b/tests/models/Group.php index 5332948d3..9e06f0773 100644 --- a/tests/models/Group.php +++ b/tests/models/Group.php @@ -9,6 +9,6 @@ class Group extends Eloquent { public function users() { - return $this->belongsToMany('User', 'test_collection', 'groups', 'users'); + return $this->belongsToMany('User', null, 'groups', 'users'); } } diff --git a/tests/models/User.php b/tests/models/User.php index 5a8d352fe..56ef54b45 100644 --- a/tests/models/User.php +++ b/tests/models/User.php @@ -35,7 +35,7 @@ public function clients() public function groups() { - return $this->belongsToMany('Group', 'test_collection', 'users', 'groups'); + return $this->belongsToMany('Group', null, 'users', 'groups'); } /**