8000 Many to Many relationships · Pull Request #70 · mongodb/laravel-mongodb · GitHub
[go: up one dir, main page]

Skip to content

Many to Many relationships #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from Nov 20, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test models added
  • Loading branch information
unknown authored and unknown committed Nov 20, 2013
commit e93b26258ce13d46db03ebbb1c071544293bf791
14 changes: 14 additions & 0 deletions tests/models/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
use Jenssegers\Mongodb\Model as Eloquent;

class Client extends Eloquent {

protected $collection = 'clients';

protected static $unguarded = true;

public function users()
{
return $this->belongsToMany('User');
}
}
15 changes: 9 additions & 6 deletions tests/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

class User extends Eloquent implements UserInterface, RemindableInterface {

protected $collection = 'users';
protected $collection = 'users';

protected $dates = array('birthday');
protected static $unguarded = true;

protected static $unguarded = true;

public function books()
public function books()
{
return $this->hasMany('Book', 'author_id');
}
Expand All @@ -27,6 +25,11 @@ public function role()
{
return $this->hasOne('Role');
}

public function clients()
{
return $this->belongsToMany('Client');
}

/**
* Get the unique identifier for the user.
Expand Down Expand Up @@ -58,4 +61,4 @@ public function getReminderEmail()
return $this->email;
}

}
}
0