Skip to content

Commit

Permalink
Updating readme for #75
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Nov 29, 2013
1 parent 34ea812 commit 9829d49
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/models/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
2 changes: 1 addition & 1 deletion tests/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down

0 comments on commit 9829d49

Please sign in to comment.