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
5454ac96
Unverified
Commit
5454ac96
authored
Nov 03, 2017
by
Jens Segers
Committed by
GitHub
Nov 03, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1317 from DoSomething/chunkById-5.5
Fix issue with chunkById.
parents
cf15156f
62611090
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
0 deletions
+44
-0
Builder.php
src/Jenssegers/Mongodb/Eloquent/Builder.php
+8
-0
Builder.php
src/Jenssegers/Mongodb/Query/Builder.php
+22
-0
ModelTest.php
tests/ModelTest.php
+14
-0
No files found.
src/Jenssegers/Mongodb/Eloquent/Builder.php
View file @
5454ac96
...
...
@@ -143,6 +143,14 @@ class Builder extends EloquentBuilder
return
parent
::
decrement
(
$column
,
$amount
,
$extra
);
}
/**
* @inheritdoc
*/
public
function
chunkById
(
$count
,
callable
$callback
,
$column
=
'_id'
,
$alias
=
null
)
{
return
parent
::
chunkById
(
$count
,
$callback
,
$column
,
$alias
);
}
/**
* @inheritdoc
*/
...
...
src/Jenssegers/Mongodb/Query/Builder.php
View file @
5454ac96
...
...
@@ -618,6 +618,28 @@ class Builder extends BaseBuilder
return
$this
->
increment
(
$column
,
-
1
*
$amount
,
$extra
,
$options
);
}
/**
* @inheritdoc
*/
public
function
chunkById
(
$count
,
callable
$callback
,
$column
=
'_id'
,
$alias
=
null
)
{
return
parent
::
chunkById
(
$count
,
$callback
,
$column
,
$alias
);
}
/**
* @inheritdoc
*/
public
function
forPageAfterId
(
$perPage
=
15
,
$lastId
=
0
,
$column
=
'_id'
)
{
// When using ObjectIDs to paginate, we need to use a hex string as the
// "minimum" ID rather than the integer zero so the '$lt' query works.
if
(
$column
===
'_id'
&&
$lastId
===
0
)
{
$lastId
=
'000000000000000000000000'
;
}
return
parent
::
forPageAfterId
(
$perPage
,
$lastId
,
$column
);
}
/**
* @inheritdoc
*/
...
...
tests/ModelTest.php
View file @
5454ac96
...
...
@@ -534,4 +534,18 @@ class ModelTest extends TestCase
$user
->
birthday
=
new
DateTime
(
'19 august 1989'
);
$this
->
assertEmpty
(
$user
->
getDirty
());
}
public
function
testChunkById
()
{
User
::
create
([
'name'
=>
'fork'
,
'tags'
=>
[
'sharp'
,
'pointy'
]]);
User
::
create
([
'name'
=>
'spork'
,
'tags'
=>
[
'sharp'
,
'pointy'
,
'round'
,
'bowl'
]]);
User
::
create
([
'name'
=>
'spoon'
,
'tags'
=>
[
'round'
,
'bowl'
]]);
$count
=
0
;
User
::
chunkById
(
2
,
function
(
$items
)
use
(
&
$count
)
{
$count
+=
count
(
$items
);
});
$this
->
assertEquals
(
3
,
$count
);
}
}
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