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
6cc912f6
Commit
6cc912f6
authored
Feb 04, 2015
by
Jens Segers
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into develop
parents
d1a212cd
4fc8f12f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
414 additions
and
396 deletions
+414
-396
README.md
README.md
+387
-390
Connection.php
src/Jenssegers/Mongodb/Connection.php
+1
-1
Model.php
src/Jenssegers/Mongodb/Model.php
+0
-2
Builder.php
src/Jenssegers/Mongodb/Query/Builder.php
+7
-3
RelationsTest.php
tests/RelationsTest.php
+19
-0
No files found.
README.md
View file @
6cc912f6
This diff is collapsed.
Click to expand it.
src/Jenssegers/Mongodb/Connection.php
View file @
6cc912f6
...
...
@@ -33,7 +33,7 @@ class Connection extends \Illuminate\Database\Connection {
// Build the connection string
$dsn
=
$this
->
getDsn
(
$config
);
// You can pass options directly to the MogoClient constructor
// You can pass options directly to the Mo
n
goClient constructor
$options
=
array_get
(
$config
,
'options'
,
array
());
// Create the connection
...
...
src/Jenssegers/Mongodb/Model.php
View file @
6cc912f6
<?php
namespace
Jenssegers\Mongodb
;
use
Illuminate\Database\Eloquent\Collection
;
use
Jenssegers\Mongodb\DatabaseManager
as
Resolver
;
use
Jenssegers\Mongodb\Eloquent\Builder
;
use
Jenssegers\Mongodb\Query\Builder
as
QueryBuilder
;
use
Illuminate\Database\Eloquent\Relations\Relation
;
use
Jenssegers\Mongodb\Relations\EmbedsOneOrMany
;
use
Jenssegers\Mongodb\Relations\EmbedsMany
;
...
...
src/Jenssegers/Mongodb/Query/Builder.php
View file @
6cc912f6
...
...
@@ -715,16 +715,20 @@ class Builder extends QueryBuilder {
*/
public
function
where
(
$column
,
$operator
=
null
,
$value
=
null
,
$boolean
=
'and'
)
{
$params
=
func_get_args
();
// Remove the leading $ from operators.
if
(
func_num_args
()
==
3
)
{
$operator
=
&
$params
[
1
];
if
(
starts_with
(
$operator
,
'$'
))
{
$operator
=
substr
(
$operator
,
1
);
}
}
return
parent
::
where
(
$column
,
$operator
,
$value
,
$boolean
);
return
call_user_func_array
(
'parent::where'
,
$params
);
}
/**
...
...
@@ -883,14 +887,14 @@ class Builder extends QueryBuilder {
{
extract
(
$where
);
return
array
(
$column
=>
array
(
'$in'
=>
$values
));
return
array
(
$column
=>
array
(
'$in'
=>
array_values
(
$values
)
));
}
protected
function
compileWhereNotIn
(
$where
)
{
extract
(
$where
);
return
array
(
$column
=>
array
(
'$nin'
=>
$values
));
return
array
(
$column
=>
array
(
'$nin'
=>
array_values
(
$values
)
));
}
protected
function
compileWhereNull
(
$where
)
...
...
tests/RelationsTest.php
View file @
6cc912f6
...
...
@@ -258,6 +258,25 @@ class RelationsTest extends TestCase {
$this
->
assertStringStartsWith
(
'synced'
,
$user
->
clients
[
1
]
->
name
);
}
public
function
testBelongsToManySync
()
{
// create test instances
$user
=
User
::
create
(
array
(
'name'
=>
'John Doe'
));
$client1
=
Client
::
create
(
array
(
'name'
=>
'Pork Pies Ltd.'
))
->
_id
;
$client2
=
Client
::
create
(
array
(
'name'
=>
'Buffet Bar Inc.'
))
->
_id
;
// Sync multiple
$user
->
clients
()
->
sync
(
array
(
$client1
,
$client2
));
$this
->
assertCount
(
2
,
$user
->
clients
);
// Refresh user
$user
=
User
::
where
(
'name'
,
'='
,
'John Doe'
)
->
first
();
// Sync single
$user
->
clients
()
->
sync
(
array
(
$client1
));
$this
->
assertCount
(
1
,
$user
->
clients
);
}
public
function
testBelongsToManyCustom
()
{
$user
=
User
::
create
(
array
(
'name'
=>
'John Doe'
));
...
...
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