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
7e8a9cc4
Commit
7e8a9cc4
authored
Aug 09, 2014
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pull/push logic
parent
bab6b2d2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
Builder.php
src/Jenssegers/Mongodb/Query/Builder.php
+10
-2
No files found.
src/Jenssegers/Mongodb/Query/Builder.php
View file @
7e8a9cc4
...
...
@@ -515,11 +515,14 @@ class Builder extends \Illuminate\Database\Query\Builder {
// Use the addToSet operator in case we only want unique items.
$operator
=
$unique
?
'$addToSet'
:
'$push'
;
// Check if we are pushing multiple values.
$multipleValues
=
(
is_array
(
$value
)
and
array_keys
(
$value
)
===
range
(
0
,
count
(
$value
)
-
1
));
if
(
is_array
(
$column
))
{
$query
=
array
(
$operator
=>
$column
);
}
else
if
(
is_array
(
$value
)
)
else
if
(
$multipleValues
)
{
$query
=
array
(
$operator
=>
array
(
$column
=>
array
(
'$each'
=>
$value
)));
}
...
...
@@ -540,8 +543,13 @@ class Builder extends \Illuminate\Database\Query\Builder {
*/
public
function
pull
(
$column
,
$value
=
null
)
{
var_dump
(
$value
);
// Check if we passed an associative array.
$multipleValues
=
(
is_array
(
$value
)
and
array_keys
(
$value
)
===
range
(
0
,
count
(
$value
)
-
1
));
// If we are pulling multiple values, we need to use $pullAll.
$operator
=
is_array
(
$value
)
?
'$pullAll'
:
'$pull'
;
$operator
=
$multipleValues
?
'$pullAll'
:
'$pull'
;
if
(
is_array
(
$column
))
{
...
...
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