Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
92debf56
Commit
92debf56
authored
Nov 27, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:jenssegers/Laravel-MongoDB
parents
fe90f122
57c5bedb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
BelongsToMany.php
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
+6
-0
RelationsTest.php
tests/RelationsTest.php
+7
-4
No files found.
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
View file @
92debf56
...
@@ -170,6 +170,9 @@ class BelongsToMany extends EloquentBelongsToMany {
...
@@ -170,6 +170,9 @@ class BelongsToMany extends EloquentBelongsToMany {
$query
=
$this
->
newParentQuery
();
$query
=
$this
->
newParentQuery
();
// Generate a new related query instance
$related
=
$this
->
related
->
newInstance
();
// If associated IDs were passed to the method we will only delete those
// If associated IDs were passed to the method we will only delete those
// associations, otherwise all of the association ties will be broken.
// associations, otherwise all of the association ties will be broken.
// We'll return the numbers of affected rows when we do the deletes.
// We'll return the numbers of affected rows when we do the deletes.
...
@@ -189,6 +192,9 @@ class BelongsToMany extends EloquentBelongsToMany {
...
@@ -189,6 +192,9 @@ class BelongsToMany extends EloquentBelongsToMany {
{
{
$query
->
pull
(
$this
->
otherKey
,
$id
);
$query
->
pull
(
$this
->
otherKey
,
$id
);
}
}
// Remove the relation from the related model
$related
->
pull
(
$this
->
foreignKey
,
$this
->
parent
->
getKey
());
return
count
(
$ids
);
return
count
(
$ids
);
}
}
...
...
tests/RelationsTest.php
View file @
92debf56
...
@@ -204,8 +204,8 @@ class RelationsTest extends PHPUnit_Framework_TestCase {
...
@@ -204,8 +204,8 @@ class RelationsTest extends PHPUnit_Framework_TestCase {
);
);
$moreClients
=
array
(
$moreClients
=
array
(
Client
::
create
(
array
(
'name'
=>
'Boloni Ltd.'
))
->
_id
,
Client
::
create
(
array
(
'name'
=>
'
synced
Boloni Ltd.'
))
->
_id
,
Client
::
create
(
array
(
'name'
=>
'Meatballs Inc.'
))
->
_id
Client
::
create
(
array
(
'name'
=>
'
synced
Meatballs Inc.'
))
->
_id
);
);
// Sync multiple records
// Sync multiple records
...
@@ -224,7 +224,10 @@ class RelationsTest extends PHPUnit_Framework_TestCase {
...
@@ -224,7 +224,10 @@ class RelationsTest extends PHPUnit_Framework_TestCase {
$user
=
User
::
with
(
'clients'
)
->
find
(
$user
->
_id
);
$user
=
User
::
with
(
'clients'
)
->
find
(
$user
->
_id
);
// Assert there are now 4 client objects in the relationship
// Assert there are now still 2 client objects in the relationship
$this
->
assertCount
(
4
,
$user
->
clients
);
$this
->
assertCount
(
2
,
$user
->
clients
);
// Assert that the new relationships name start with synced
$this
->
assertStringStartsWith
(
'synced'
,
$user
->
clients
[
0
]
->
name
);
$this
->
assertStringStartsWith
(
'synced'
,
$user
->
clients
[
1
]
->
name
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment