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
b379bd39
Unverified
Commit
b379bd39
authored
Mar 05, 2020
by
Divine
Committed by
GitHub
Mar 05, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1986 from divine/analysis-KZ0ZE3
[4.x] Apply fixes from StyleCI
parents
444e90df
56b874de
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
53 changed files
with
242 additions
and
202 deletions
+242
-202
DatabaseTokenRepository.php
src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php
+3
-3
PasswordBrokerManager.php
src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php
+1
-1
PasswordResetServiceProvider.php
src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php
+1
-1
Collection.php
src/Jenssegers/Mongodb/Collection.php
+1
-1
Connection.php
src/Jenssegers/Mongodb/Connection.php
+17
-16
Builder.php
src/Jenssegers/Mongodb/Eloquent/Builder.php
+10
-10
HybridRelations.php
src/Jenssegers/Mongodb/Eloquent/HybridRelations.php
+16
-16
Model.php
src/Jenssegers/Mongodb/Eloquent/Model.php
+28
-28
SoftDeletes.php
src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php
+1
-1
QueriesRelationships.php
src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php
+5
-5
MongodbQueueServiceProvider.php
src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php
+2
-2
MongodbServiceProvider.php
src/Jenssegers/Mongodb/MongodbServiceProvider.php
+1
-0
Builder.php
src/Jenssegers/Mongodb/Query/Builder.php
+51
-47
MongoFailedJobProvider.php
...enssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php
+2
-1
MongoQueue.php
src/Jenssegers/Mongodb/Queue/MongoQueue.php
+3
-3
BelongsTo.php
src/Jenssegers/Mongodb/Relations/BelongsTo.php
+3
-3
BelongsToMany.php
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
+18
-17
HasMany.php
src/Jenssegers/Mongodb/Relations/HasMany.php
+1
-1
HasOne.php
src/Jenssegers/Mongodb/Relations/HasOne.php
+1
-1
MorphTo.php
src/Jenssegers/Mongodb/Relations/MorphTo.php
+2
-2
Blueprint.php
src/Jenssegers/Mongodb/Schema/Blueprint.php
+11
-8
Builder.php
src/Jenssegers/Mongodb/Schema/Builder.php
+10
-10
DatabasePresenceVerifier.php
...enssegers/Mongodb/Validation/DatabasePresenceVerifier.php
+1
-1
AuthTest.php
tests/AuthTest.php
+1
-0
CollectionTest.php
tests/CollectionTest.php
+1
-0
ConnectionTest.php
tests/ConnectionTest.php
+3
-2
DsnTest.php
tests/DsnTest.php
+1
-0
GeospatialTest.php
tests/GeospatialTest.php
+1
-0
HybridRelationsTest.php
tests/HybridRelationsTest.php
+5
-4
ModelTest.php
tests/ModelTest.php
+1
-0
QueryBuilderTest.php
tests/QueryBuilderTest.php
+11
-10
QueryTest.php
tests/QueryTest.php
+1
-0
QueueTest.php
tests/QueueTest.php
+1
-0
RelationsTest.php
tests/RelationsTest.php
+1
-0
SchemaTest.php
tests/SchemaTest.php
+1
-0
SeederTest.php
tests/SeederTest.php
+1
-0
TestCase.php
tests/TestCase.php
+1
-0
ValidationTest.php
tests/ValidationTest.php
+1
-0
database.php
tests/config/database.php
+1
-1
Address.php
tests/models/Address.php
+1
-0
Book.php
tests/models/Book.php
+2
-1
Client.php
tests/models/Client.php
+1
-0
Group.php
tests/models/Group.php
+1
-0
Item.php
tests/models/Item.php
+2
-1
Location.php
tests/models/Location.php
+1
-0
MysqlBook.php
tests/models/MysqlBook.php
+2
-1
MysqlRole.php
tests/models/MysqlRole.php
+2
-1
MysqlUser.php
tests/models/MysqlUser.php
+2
-1
Photo.php
tests/models/Photo.php
+1
-0
Role.php
tests/models/Role.php
+1
-0
Scoped.php
tests/models/Scoped.php
+1
-0
Soft.php
tests/models/Soft.php
+2
-1
User.php
tests/models/User.php
+2
-1
No files found.
src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php
View file @
b379bd39
...
@@ -11,7 +11,7 @@ use MongoDB\BSON\UTCDateTime;
...
@@ -11,7 +11,7 @@ use MongoDB\BSON\UTCDateTime;
class
DatabaseTokenRepository
extends
BaseDatabaseTokenRepository
class
DatabaseTokenRepository
extends
BaseDatabaseTokenRepository
{
{
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
getPayload
(
$email
,
$token
)
protected
function
getPayload
(
$email
,
$token
)
{
{
...
@@ -23,7 +23,7 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository
...
@@ -23,7 +23,7 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
tokenExpired
(
$createdAt
)
protected
function
tokenExpired
(
$createdAt
)
{
{
...
@@ -33,7 +33,7 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository
...
@@ -33,7 +33,7 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
tokenRecentlyCreated
(
$createdAt
)
protected
function
tokenRecentlyCreated
(
$createdAt
)
{
{
...
...
src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php
View file @
b379bd39
...
@@ -7,7 +7,7 @@ use Illuminate\Auth\Passwords\PasswordBrokerManager as BasePasswordBrokerManager
...
@@ -7,7 +7,7 @@ use Illuminate\Auth\Passwords\PasswordBrokerManager as BasePasswordBrokerManager
class
PasswordBrokerManager
extends
BasePasswordBrokerManager
class
PasswordBrokerManager
extends
BasePasswordBrokerManager
{
{
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
createTokenRepository
(
array
$config
)
protected
function
createTokenRepository
(
array
$config
)
{
{
...
...
src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php
View file @
b379bd39
...
@@ -29,7 +29,7 @@ class PasswordResetServiceProvider extends BasePasswordResetServiceProvider
...
@@ -29,7 +29,7 @@ class PasswordResetServiceProvider extends BasePasswordResetServiceProvider
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
registerPasswordBroker
()
protected
function
registerPasswordBroker
()
{
{
...
...
src/Jenssegers/Mongodb/Collection.php
View file @
b379bd39
...
@@ -65,7 +65,7 @@ class Collection
...
@@ -65,7 +65,7 @@ class Collection
}
}
}
}
$queryString
=
$this
->
collection
->
getCollectionName
()
.
'.'
.
$method
.
'('
.
implode
(
','
,
$query
)
.
')'
;
$queryString
=
$this
->
collection
->
getCollectionName
()
.
'.'
.
$method
.
'('
.
implode
(
','
,
$query
)
.
')'
;
$this
->
connection
->
logQuery
(
$queryString
,
[],
$time
);
$this
->
connection
->
logQuery
(
$queryString
,
[],
$time
);
}
}
...
...
src/Jenssegers/Mongodb/Connection.php
View file @
b379bd39
...
@@ -85,7 +85,7 @@ class Connection extends BaseConnection
...
@@ -85,7 +85,7 @@ class Connection extends BaseConnection
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getSchemaBuilder
()
public
function
getSchemaBuilder
()
{
{
...
@@ -119,7 +119,7 @@ class Connection extends BaseConnection
...
@@ -119,7 +119,7 @@ class Connection extends BaseConnection
}
}
/**
/**
* Get the name of the default database based on db config or try to detect it from dsn
* Get the name of the default database based on db config or try to detect it from dsn
.
* @param string $dsn
* @param string $dsn
* @param array $config
* @param array $config
* @return string
* @return string
...
@@ -131,7 +131,7 @@ class Connection extends BaseConnection
...
@@ -131,7 +131,7 @@ class Connection extends BaseConnection
if
(
preg_match
(
'/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s'
,
$dsn
,
$matches
))
{
if
(
preg_match
(
'/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s'
,
$dsn
,
$matches
))
{
$config
[
'database'
]
=
$matches
[
1
];
$config
[
'database'
]
=
$matches
[
1
];
}
else
{
}
else
{
throw
new
InvalidArgumentException
(
"Database is not properly configured."
);
throw
new
InvalidArgumentException
(
'Database is not properly configured.'
);
}
}
}
}
...
@@ -155,10 +155,10 @@ class Connection extends BaseConnection
...
@@ -155,10 +155,10 @@ class Connection extends BaseConnection
}
}
// Check if the credentials are not already set in the options
// Check if the credentials are not already set in the options
if
(
!
isset
(
$options
[
'username'
])
&&
!
empty
(
$config
[
'username'
]))
{
if
(
!
isset
(
$options
[
'username'
])
&&
!
empty
(
$config
[
'username'
]))
{
$options
[
'username'
]
=
$config
[
'username'
];
$options
[
'username'
]
=
$config
[
'username'
];
}
}
if
(
!
isset
(
$options
[
'password'
])
&&
!
empty
(
$config
[
'password'
]))
{
if
(
!
isset
(
$options
[
'password'
])
&&
!
empty
(
$config
[
'password'
]))
{
$options
[
'password'
]
=
$config
[
'password'
];
$options
[
'password'
]
=
$config
[
'password'
];
}
}
...
@@ -166,7 +166,7 @@ class Connection extends BaseConnection
...
@@ -166,7 +166,7 @@ class Connection extends BaseConnection
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
disconnect
()
public
function
disconnect
()
{
{
...
@@ -180,7 +180,7 @@ class Connection extends BaseConnection
...
@@ -180,7 +180,7 @@ class Connection extends BaseConnection
*/
*/
protected
function
hasDsnString
(
array
$config
)
protected
function
hasDsnString
(
array
$config
)
{
{
return
isset
(
$config
[
'dsn'
])
&&
!
empty
(
$config
[
'dsn'
]);
return
isset
(
$config
[
'dsn'
])
&&
!
empty
(
$config
[
'dsn'
]);
}
}
/**
/**
...
@@ -205,14 +205,15 @@ class Connection extends BaseConnection
...
@@ -205,14 +205,15 @@ class Connection extends BaseConnection
foreach
(
$hosts
as
&
$host
)
{
foreach
(
$hosts
as
&
$host
)
{
// Check if we need to add a port to the host
// Check if we need to add a port to the host
if
(
strpos
(
$host
,
':'
)
===
false
&&
!
empty
(
$config
[
'port'
]))
{
if
(
strpos
(
$host
,
':'
)
===
false
&&
!
empty
(
$config
[
'port'
]))
{
$host
=
$host
.
':'
.
$config
[
'port'
];
$host
=
$host
.
':'
.
$config
[
'port'
];
}
}
}
}
// Check if we want to authenticate against a specific database.
// Check if we want to authenticate against a specific database.
$auth_database
=
isset
(
$config
[
'options'
])
&&
!
empty
(
$config
[
'options'
][
'database'
])
?
$config
[
'options'
][
'database'
]
:
null
;
$auth_database
=
isset
(
$config
[
'options'
])
&&
!
empty
(
$config
[
'options'
][
'database'
])
?
$config
[
'options'
][
'database'
]
:
null
;
return
'mongodb://'
.
implode
(
','
,
$hosts
)
.
(
$auth_database
?
'/'
.
$auth_database
:
''
);
return
'mongodb://'
.
implode
(
','
,
$hosts
)
.
(
$auth_database
?
'/'
.
$auth_database
:
''
);
}
}
/**
/**
...
@@ -228,7 +229,7 @@ class Connection extends BaseConnection
...
@@ -228,7 +229,7 @@ class Connection extends BaseConnection
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getElapsedTime
(
$start
)
public
function
getElapsedTime
(
$start
)
{
{
...
@@ -236,7 +237,7 @@ class Connection extends BaseConnection
...
@@ -236,7 +237,7 @@ class Connection extends BaseConnection
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getDriverName
()
public
function
getDriverName
()
{
{
...
@@ -244,7 +245,7 @@ class Connection extends BaseConnection
...
@@ -244,7 +245,7 @@ class Connection extends BaseConnection
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
getDefaultPostProcessor
()
protected
function
getDefaultPostProcessor
()
{
{
...
@@ -252,7 +253,7 @@ class Connection extends BaseConnection
...
@@ -252,7 +253,7 @@ class Connection extends BaseConnection
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
getDefaultQueryGrammar
()
protected
function
getDefaultQueryGrammar
()
{
{
...
@@ -260,7 +261,7 @@ class Connection extends BaseConnection
...
@@ -260,7 +261,7 @@ class Connection extends BaseConnection
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
getDefaultSchemaGrammar
()
protected
function
getDefaultSchemaGrammar
()
{
{
...
...
src/Jenssegers/Mongodb/Eloquent/Builder.php
View file @
b379bd39
...
@@ -31,7 +31,7 @@ class Builder extends EloquentBuilder
...
@@ -31,7 +31,7 @@ class Builder extends EloquentBuilder
];
];
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
update
(
array
$values
,
array
$options
=
[])
public
function
update
(
array
$values
,
array
$options
=
[])
{
{
...
@@ -39,7 +39,7 @@ class Builder extends EloquentBuilder
...
@@ -39,7 +39,7 @@ class Builder extends EloquentBuilder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
insert
(
array
$values
)
public
function
insert
(
array
$values
)
{
{
...
@@ -47,7 +47,7 @@ class Builder extends EloquentBuilder
...
@@ -47,7 +47,7 @@ class Builder extends EloquentBuilder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
insertGetId
(
array
$values
,
$sequence
=
null
)
public
function
insertGetId
(
array
$values
,
$sequence
=
null
)
{
{
...
@@ -55,7 +55,7 @@ class Builder extends EloquentBuilder
...
@@ -55,7 +55,7 @@ class Builder extends EloquentBuilder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
delete
()
public
function
delete
()
{
{
...
@@ -63,7 +63,7 @@ class Builder extends EloquentBuilder
...
@@ -63,7 +63,7 @@ class Builder extends EloquentBuilder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
increment
(
$column
,
$amount
=
1
,
array
$extra
=
[])
public
function
increment
(
$column
,
$amount
=
1
,
array
$extra
=
[])
{
{
...
@@ -71,7 +71,7 @@ class Builder extends EloquentBuilder
...
@@ -71,7 +71,7 @@ class Builder extends EloquentBuilder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
decrement
(
$column
,
$amount
=
1
,
array
$extra
=
[])
public
function
decrement
(
$column
,
$amount
=
1
,
array
$extra
=
[])
{
{
...
@@ -79,7 +79,7 @@ class Builder extends EloquentBuilder
...
@@ -79,7 +79,7 @@ class Builder extends EloquentBuilder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
chunkById
(
$count
,
callable
$callback
,
$column
=
'_id'
,
$alias
=
null
)
public
function
chunkById
(
$count
,
callable
$callback
,
$column
=
'_id'
,
$alias
=
null
)
{
{
...
@@ -87,7 +87,7 @@ class Builder extends EloquentBuilder
...
@@ -87,7 +87,7 @@ class Builder extends EloquentBuilder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
raw
(
$expression
=
null
)
public
function
raw
(
$expression
=
null
)
{
{
...
@@ -116,13 +116,13 @@ class Builder extends EloquentBuilder
...
@@ -116,13 +116,13 @@ class Builder extends EloquentBuilder
* Add the "updated at" column to an array of values.
* Add the "updated at" column to an array of values.
* TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e
* TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e
* wiil be reverted
* wiil be reverted
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791
.
* @param array $values
* @param array $values
* @return array
* @return array
*/
*/
protected
function
addUpdatedAtColumn
(
array
$values
)
protected
function
addUpdatedAtColumn
(
array
$values
)
{
{
if
(
!
$this
->
model
->
usesTimestamps
()
||
$this
->
model
->
getUpdatedAtColumn
()
===
null
)
{
if
(
!
$this
->
model
->
usesTimestamps
()
||
$this
->
model
->
getUpdatedAtColumn
()
===
null
)
{
return
$values
;
return
$values
;
}
}
...
...
src/Jenssegers/Mongodb/Eloquent/HybridRelations.php
View file @
b379bd39
...
@@ -9,8 +9,8 @@ use Jenssegers\Mongodb\Relations\BelongsTo;
...
@@ -9,8 +9,8 @@ use Jenssegers\Mongodb\Relations\BelongsTo;
use
Jenssegers\Mongodb\Relations\BelongsToMany
;
use
Jenssegers\Mongodb\Relations\BelongsToMany
;
use
Jenssegers\Mongodb\Relations\HasMany
;
use
Jenssegers\Mongodb\Relations\HasMany
;
use
Jenssegers\Mongodb\Relations\HasOne
;
use
Jenssegers\Mongodb\Relations\HasOne
;
use
Jenssegers\Mongodb\Relations\MorphTo
;
use
Jenssegers\Mongodb\Relations\MorphMany
;
use
Jenssegers\Mongodb\Relations\MorphMany
;
use
Jenssegers\Mongodb\Relations\MorphTo
;
trait
HybridRelations
trait
HybridRelations
{
{
...
@@ -24,7 +24,7 @@ trait HybridRelations
...
@@ -24,7 +24,7 @@ trait HybridRelations
public
function
hasOne
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
public
function
hasOne
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
{
{
// Check if it is a relation with an original model.
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
return
parent
::
hasOne
(
$related
,
$foreignKey
,
$localKey
);
return
parent
::
hasOne
(
$related
,
$foreignKey
,
$localKey
);
}
}
...
@@ -49,13 +49,13 @@ trait HybridRelations
...
@@ -49,13 +49,13 @@ trait HybridRelations
public
function
morphOne
(
$related
,
$name
,
$type
=
null
,
$id
=
null
,
$localKey
=
null
)
public
function
morphOne
(
$related
,
$name
,
$type
=
null
,
$id
=
null
,
$localKey
=
null
)
{
{
// Check if it is a relation with an original model.
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
return
parent
::
morphOne
(
$related
,
$name
,
$type
,
$id
,
$localKey
);
return
parent
::
morphOne
(
$related
,
$name
,
$type
,
$id
,
$localKey
);
}
}
$instance
=
new
$related
;
$instance
=
new
$related
;
list
(
$type
,
$id
)
=
$this
->
getMorphs
(
$name
,
$type
,
$id
);
[
$type
,
$id
]
=
$this
->
getMorphs
(
$name
,
$type
,
$id
);
$localKey
=
$localKey
?:
$this
->
getKeyName
();
$localKey
=
$localKey
?:
$this
->
getKeyName
();
...
@@ -72,7 +72,7 @@ trait HybridRelations
...
@@ -72,7 +72,7 @@ trait HybridRelations
public
function
hasMany
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
public
function
hasMany
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
{
{
// Check if it is a relation with an original model.
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
return
parent
::
hasMany
(
$related
,
$foreignKey
,
$localKey
);
return
parent
::
hasMany
(
$related
,
$foreignKey
,
$localKey
);
}
}
...
@@ -97,7 +97,7 @@ trait HybridRelations
...
@@ -97,7 +97,7 @@ trait HybridRelations
public
function
morphMany
(
$related
,
$name
,
$type
=
null
,
$id
=
null
,
$localKey
=
null
)
public
function
morphMany
(
$related
,
$name
,
$type
=
null
,
$id
=
null
,
$localKey
=
null
)
{
{
// Check if it is a relation with an original model.
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
return
parent
::
morphMany
(
$related
,
$name
,
$type
,
$id
,
$localKey
);
return
parent
::
morphMany
(
$related
,
$name
,
$type
,
$id
,
$localKey
);
}
}
...
@@ -106,7 +106,7 @@ trait HybridRelations
...
@@ -106,7 +106,7 @@ trait HybridRelations
// Here we will gather up the morph type and ID for the relationship so that we
// Here we will gather up the morph type and ID for the relationship so that we
// can properly query the intermediate table of a relation. Finally, we will
// can properly query the intermediate table of a relation. Finally, we will
// get the table and create the relationship instances for the developers.
// get the table and create the relationship instances for the developers.
list
(
$type
,
$id
)
=
$this
->
getMorphs
(
$name
,
$type
,
$id
);
[
$type
,
$id
]
=
$this
->
getMorphs
(
$name
,
$type
,
$id
);
$table
=
$instance
->
getTable
();
$table
=
$instance
->
getTable
();
...
@@ -129,13 +129,13 @@ trait HybridRelations
...
@@ -129,13 +129,13 @@ trait HybridRelations
// the calling method's name and use that as the relationship name as most
// the calling method's name and use that as the relationship name as most
// of the time this will be what we desire to use for the relationships.
// of the time this will be what we desire to use for the relationships.
if
(
$relation
===
null
)
{
if
(
$relation
===
null
)
{
list
(
$current
,
$caller
)
=
debug_backtrace
(
false
,
2
);
[
$current
,
$caller
]
=
debug_backtrace
(
false
,
2
);
$relation
=
$caller
[
'function'
];
$relation
=
$caller
[
'function'
];
}
}
// Check if it is a relation with an original model.
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
return
parent
::
belongsTo
(
$related
,
$foreignKey
,
$otherKey
,
$relation
);
return
parent
::
belongsTo
(
$related
,
$foreignKey
,
$otherKey
,
$relation
);
}
}
...
@@ -143,7 +143,7 @@ trait HybridRelations
...
@@ -143,7 +143,7 @@ trait HybridRelations
// foreign key name by using the name of the relationship function, which
// foreign key name by using the name of the relationship function, which
// when combined with an "_id" should conventionally match the columns.
// when combined with an "_id" should conventionally match the columns.
if
(
$foreignKey
===
null
)
{
if
(
$foreignKey
===
null
)
{
$foreignKey
=
Str
::
snake
(
$relation
)
.
'_id'
;
$foreignKey
=
Str
::
snake
(
$relation
)
.
'_id'
;
}
}
$instance
=
new
$related
;
$instance
=
new
$related
;
...
@@ -172,12 +172,12 @@ trait HybridRelations
...
@@ -172,12 +172,12 @@ trait HybridRelations
// since that is most likely the name of the polymorphic interface. We can
// since that is most likely the name of the polymorphic interface. We can
// use that to get both the class and foreign key that will be utilized.
// use that to get both the class and foreign key that will be utilized.
if
(
$name
===
null
)
{
if
(
$name
===
null
)
{
list
(
$current
,
$caller
)
=
debug_backtrace
(
DEBUG_BACKTRACE_IGNORE_ARGS
,
2
);
[
$current
,
$caller
]
=
debug_backtrace
(
DEBUG_BACKTRACE_IGNORE_ARGS
,
2
);
$name
=
Str
::
snake
(
$caller
[
'function'
]);
$name
=
Str
::
snake
(
$caller
[
'function'
]);
}
}
list
(
$type
,
$id
)
=
$this
->
getMorphs
(
$name
,
$type
,
$id
);
[
$type
,
$id
]
=
$this
->
getMorphs
(
$name
,
$type
,
$id
);
// If the type value is null it is probably safe to assume we're eager loading
// If the type value is null it is probably safe to assume we're eager loading
// the relationship. When that is the case we will pass in a dummy query as
// the relationship. When that is the case we will pass in a dummy query as
...
@@ -230,7 +230,7 @@ trait HybridRelations
...
@@ -230,7 +230,7 @@ trait HybridRelations
}
}
// Check if it is a relation with an original model.
// Check if it is a relation with an original model.
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
if
(
!
is_subclass_of
(
$related
,
\Jenssegers\Mongodb\Eloquent\Model
::
class
))
{
return
parent
::
belongsToMany
(
return
parent
::
belongsToMany
(
$related
,
$related
,
$collection
,
$collection
,
...
@@ -245,11 +245,11 @@ trait HybridRelations
...
@@ -245,11 +245,11 @@ trait HybridRelations
// First, we'll need to determine the foreign key and "other key" for the
// First, we'll need to determine the foreign key and "other key" for the
// relationship. Once we have determined the keys we'll make the query
// relationship. Once we have determined the keys we'll make the query
// instances as well as the relationship instances we need for this.
// instances as well as the relationship instances we need for this.
$foreignKey
=
$foreignKey
?:
$this
->
getForeignKey
()
.
's'
;
$foreignKey
=
$foreignKey
?:
$this
->
getForeignKey
()
.
's'
;
$instance
=
new
$related
;
$instance
=
new
$related
;
$otherKey
=
$otherKey
?:
$instance
->
getForeignKey
()
.
's'
;
$otherKey
=
$otherKey
?:
$instance
->
getForeignKey
()
.
's'
;
// If no table name was provided, we can guess it by concatenating the two
// If no table name was provided, we can guess it by concatenating the two
// models using underscores in alphabetical order. The two model names
// models using underscores in alphabetical order. The two model names
...
@@ -289,7 +289,7 @@ trait HybridRelations
...
@@ -289,7 +289,7 @@ trait HybridRelations
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
newEloquentBuilder
(
$query
)
public
function
newEloquentBuilder
(
$query
)
{
{
...
...
src/Jenssegers/Mongodb/Eloquent/Model.php
View file @
b379bd39
...
@@ -52,7 +52,7 @@ abstract class Model extends BaseModel
...
@@ -52,7 +52,7 @@ abstract class Model extends BaseModel
{
{
// If we don't have a value for 'id', we will use the Mongo '_id' value.
// If we don't have a value for 'id', we will use the Mongo '_id' value.
// This allows us to work with models in a more sql-like way.
// This allows us to work with models in a more sql-like way.
if
(
!
$value
&&
array_key_exists
(
'_id'
,
$this
->
attributes
))
{
if
(
!
$value
&&
array_key_exists
(
'_id'
,
$this
->
attributes
))
{
$value
=
$this
->
attributes
[
'_id'
];
$value
=
$this
->
attributes
[
'_id'
];
}
}
...
@@ -67,7 +67,7 @@ abstract class Model extends BaseModel
...
@@ -67,7 +67,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getQualifiedKeyName
()
public
function
getQualifiedKeyName
()
{
{
...
@@ -75,7 +75,7 @@ abstract class Model extends BaseModel
...
@@ -75,7 +75,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
fromDateTime
(
$value
)
public
function
fromDateTime
(
$value
)
{
{
...
@@ -85,7 +85,7 @@ abstract class Model extends BaseModel
...
@@ -85,7 +85,7 @@ abstract class Model extends BaseModel
}
}
// Let Eloquent convert the value to a DateTime instance.
// Let Eloquent convert the value to a DateTime instance.
if
(
!
$value
instanceof
DateTime
)
{
if
(
!
$value
instanceof
DateTime
)
{
$value
=
parent
::
asDateTime
(
$value
);
$value
=
parent
::
asDateTime
(
$value
);
}
}
...
@@ -93,7 +93,7 @@ abstract class Model extends BaseModel
...
@@ -93,7 +93,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
asDateTime
(
$value
)
protected
function
asDateTime
(
$value
)
{
{
...
@@ -106,7 +106,7 @@ abstract class Model extends BaseModel
...
@@ -106,7 +106,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getDateFormat
()
public
function
getDateFormat
()
{
{
...
@@ -114,7 +114,7 @@ abstract class Model extends BaseModel
...
@@ -114,7 +114,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
freshTimestamp
()
public
function
freshTimestamp
()
{
{
...
@@ -122,7 +122,7 @@ abstract class Model extends BaseModel
...
@@ -122,7 +122,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getTable
()
public
function
getTable
()
{
{
...
@@ -130,11 +130,11 @@ abstract class Model extends BaseModel
...
@@ -130,11 +130,11 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getAttribute
(
$key
)
public
function
getAttribute
(
$key
)
{
{
if
(
!
$key
)
{
if
(
!
$key
)
{
return
;
return
;
}
}
...
@@ -147,7 +147,7 @@ abstract class Model extends BaseModel
...
@@ -147,7 +147,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
getAttributeFromArray
(
$key
)
protected
function
getAttributeFromArray
(
$key
)
{
{
...
@@ -160,7 +160,7 @@ abstract class Model extends BaseModel
...
@@ -160,7 +160,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
setAttribute
(
$key
,
$value
)
public
function
setAttribute
(
$key
,
$value
)
{
{
...
@@ -184,7 +184,7 @@ abstract class Model extends BaseModel
...
@@ -184,7 +184,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
attributesToArray
()
public
function
attributesToArray
()
{
{
...
@@ -213,7 +213,7 @@ abstract class Model extends BaseModel
...
@@ -213,7 +213,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getCasts
()
public
function
getCasts
()
{
{
...
@@ -221,11 +221,11 @@ abstract class Model extends BaseModel
...
@@ -221,11 +221,11 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
originalIsEquivalent
(
$key
,
$current
)
public
function
originalIsEquivalent
(
$key
,
$current
)
{
{
if
(
!
array_key_exists
(
$key
,
$this
->
original
))
{
if
(
!
array_key_exists
(
$key
,
$this
->
original
))
{
return
false
;
return
false
;
}
}
...
@@ -274,7 +274,7 @@ abstract class Model extends BaseModel
...
@@ -274,7 +274,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
push
()
public
function
push
()
{
{
...
@@ -282,9 +282,9 @@ abstract class Model extends BaseModel
...
@@ -282,9 +282,9 @@ abstract class Model extends BaseModel
$unique
=
false
;
$unique
=
false
;
if
(
count
(
$parameters
)
===
3
)
{
if
(
count
(
$parameters
)
===
3
)
{
list
(
$column
,
$values
,
$unique
)
=
$parameters
;
[
$column
,
$values
,
$unique
]
=
$parameters
;
}
else
{
}
else
{
list
(
$column
,
$values
)
=
$parameters
;
[
$column
,
$values
]
=
$parameters
;
}
}
// Do batch push by default.
// Do batch push by default.
...
@@ -330,7 +330,7 @@ abstract class Model extends BaseModel
...
@@ -330,7 +330,7 @@ abstract class Model extends BaseModel
foreach
(
$values
as
$value
)
{
foreach
(
$values
as
$value
)
{
// Don't add duplicate values when we only want unique values.
// Don't add duplicate values when we only want unique values.
if
(
$unique
&&
(
!
is_array
(
$current
)
||
in_array
(
$value
,
$current
)))
{
if
(
$unique
&&
(
!
is_array
(
$current
)
||
in_array
(
$value
,
$current
)))
{
continue
;
continue
;
}
}
...
@@ -367,11 +367,11 @@ abstract class Model extends BaseModel
...
@@ -367,11 +367,11 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getForeignKey
()
public
function
getForeignKey
()
{
{
return
Str
::
snake
(
class_basename
(
$this
))
.
'_'
.
ltrim
(
$this
->
primaryKey
,
'_'
);
return
Str
::
snake
(
class_basename
(
$this
))
.
'_'
.
ltrim
(
$this
->
primaryKey
,
'_'
);
}
}
/**
/**
...
@@ -393,7 +393,7 @@ abstract class Model extends BaseModel
...
@@ -393,7 +393,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
newEloquentBuilder
(
$query
)
public
function
newEloquentBuilder
(
$query
)
{
{
...
@@ -401,7 +401,7 @@ abstract class Model extends BaseModel
...
@@ -401,7 +401,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
newBaseQueryBuilder
()
protected
function
newBaseQueryBuilder
()
{
{
...
@@ -411,7 +411,7 @@ abstract class Model extends BaseModel
...
@@ -411,7 +411,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
removeTableFromKey
(
$key
)
protected
function
removeTableFromKey
(
$key
)
{
{
...
@@ -433,13 +433,13 @@ abstract class Model extends BaseModel
...
@@ -433,13 +433,13 @@ abstract class Model extends BaseModel
if
(
$relation
instanceof
QueueableCollection
)
{
if
(
$relation
instanceof
QueueableCollection
)
{
foreach
(
$relation
->
getQueueableRelations
()
as
$collectionValue
)
{
foreach
(
$relation
->
getQueueableRelations
()
as
$collectionValue
)
{
$relations
[]
=
$key
.
'.'
.
$collectionValue
;
$relations
[]
=
$key
.
'.'
.
$collectionValue
;
}
}
}
}
if
(
$relation
instanceof
QueueableEntity
)
{
if
(
$relation
instanceof
QueueableEntity
)
{
foreach
(
$relation
->
getQueueableRelations
()
as
$entityKey
=>
$entityValue
)
{
foreach
(
$relation
->
getQueueableRelations
()
as
$entityKey
=>
$entityValue
)
{
$relations
[]
=
$key
.
'.'
.
$entityValue
;
$relations
[]
=
$key
.
'.'
.
$entityValue
;
}
}
}
}
}
}
...
@@ -463,7 +463,7 @@ abstract class Model extends BaseModel
...
@@ -463,7 +463,7 @@ abstract class Model extends BaseModel
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
__call
(
$method
,
$parameters
)
public
function
__call
(
$method
,
$parameters
)
{
{
...
...
src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php
View file @
b379bd39
...
@@ -7,7 +7,7 @@ trait SoftDeletes
...
@@ -7,7 +7,7 @@ trait SoftDeletes
use
\Illuminate\Database\Eloquent\SoftDeletes
;
use
\Illuminate\Database\Eloquent\SoftDeletes
;
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getQualifiedDeletedAtColumn
()
public
function
getQualifiedDeletedAtColumn
()
{
{
...
...
src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php
View file @
b379bd39
...
@@ -71,7 +71,7 @@ trait QueriesRelationships
...
@@ -71,7 +71,7 @@ trait QueriesRelationships
}
}
/**
/**
* Compare across databases
* Compare across databases
.
* @param Relation $relation
* @param Relation $relation
* @param string $operator
* @param string $operator
* @param int $count
* @param int $count
...
@@ -91,7 +91,7 @@ trait QueriesRelationships
...
@@ -91,7 +91,7 @@ trait QueriesRelationships
$not
=
in_array
(
$operator
,
[
'<'
,
'<='
,
'!='
]);
$not
=
in_array
(
$operator
,
[
'<'
,
'<='
,
'!='
]);
// If we are comparing to 0, we need an additional $not flip.
// If we are comparing to 0, we need an additional $not flip.
if
(
$count
==
0
)
{
if
(
$count
==
0
)
{
$not
=
!
$not
;
$not
=
!
$not
;
}
}
$relations
=
$hasQuery
->
pluck
(
$this
->
getHasCompareKey
(
$relation
));
$relations
=
$hasQuery
->
pluck
(
$this
->
getHasCompareKey
(
$relation
));
...
@@ -149,7 +149,7 @@ trait QueriesRelationships
...
@@ -149,7 +149,7 @@ trait QueriesRelationships
}
}
/**
/**
* Returns key we are constraining this parent model's query with
* Returns key we are constraining this parent model's query with
.
* @param Relation $relation
* @param Relation $relation
* @return string
* @return string
* @throws Exception
* @throws Exception
...
@@ -164,10 +164,10 @@ trait QueriesRelationships
...
@@ -164,10 +164,10 @@ trait QueriesRelationships
return
$relation
->
getForeignKeyName
();
return
$relation
->
getForeignKeyName
();
}
}
if
(
$relation
instanceof
BelongsToMany
&&
!
$this
->
isAcrossConnections
(
$relation
))
{
if
(
$relation
instanceof
BelongsToMany
&&
!
$this
->
isAcrossConnections
(
$relation
))
{
return
$this
->
model
->
getKeyName
();
return
$this
->
model
->
getKeyName
();
}
}
throw
new
Exception
(
class_basename
(
$relation
)
.
' is not supported for hybrid query constraints.'
);
throw
new
Exception
(
class_basename
(
$relation
)
.
' is not supported for hybrid query constraints.'
);
}
}
}
}
src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php
View file @
b379bd39
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
namespace
Jenssegers\Mongodb
;
namespace
Jenssegers\Mongodb
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Queue\QueueServiceProvider
;
use
Illuminate\Queue\QueueServiceProvider
;
use
Illuminate\Support\Facades\DB
;
use
Jenssegers\Mongodb\Queue\Failed\MongoFailedJobProvider
;
use
Jenssegers\Mongodb\Queue\Failed\MongoFailedJobProvider
;
class
MongodbQueueServiceProvider
extends
QueueServiceProvider
class
MongodbQueueServiceProvider
extends
QueueServiceProvider
{
{
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
registerFailedJobServices
()
protected
function
registerFailedJobServices
()
{
{
...
...
src/Jenssegers/Mongodb/MongodbServiceProvider.php
View file @
b379bd39
...
@@ -27,6 +27,7 @@ class MongodbServiceProvider extends ServiceProvider
...
@@ -27,6 +27,7 @@ class MongodbServiceProvider extends ServiceProvider
$this
->
app
->
resolving
(
'db'
,
function
(
$db
)
{
$this
->
app
->
resolving
(
'db'
,
function
(
$db
)
{
$db
->
extend
(
'mongodb'
,
function
(
$config
,
$name
)
{
$db
->
extend
(
'mongodb'
,
function
(
$config
,
$name
)
{
$config
[
'name'
]
=
$name
;
$config
[
'name'
]
=
$name
;
return
new
Connection
(
$config
);
return
new
Connection
(
$config
);
});
});
});
});
...
...
src/Jenssegers/Mongodb/Query/Builder.php
View file @
b379bd39
This diff is collapsed.
Click to expand it.
src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php
View file @
b379bd39
...
@@ -34,6 +34,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
...
@@ -34,6 +34,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
$all
=
array_map
(
function
(
$job
)
{
$all
=
array_map
(
function
(
$job
)
{
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
return
(
object
)
$job
;
return
(
object
)
$job
;
},
$all
);
},
$all
);
...
@@ -49,7 +50,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
...
@@ -49,7 +50,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
{
{
$job
=
$this
->
getTable
()
->
find
(
$id
);
$job
=
$this
->
getTable
()
->
find
(
$id
);
if
(
!
$job
)
{
if
(
!
$job
)
{
return
;
return
;
}
}
...
...
src/Jenssegers/Mongodb/Queue/MongoQueue.php
View file @
b379bd39
...
@@ -22,7 +22,7 @@ class MongoQueue extends DatabaseQueue
...
@@ -22,7 +22,7 @@ class MongoQueue extends DatabaseQueue
protected
$connectionName
;
protected
$connectionName
;
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
__construct
(
Connection
$database
,
$table
,
$default
=
'default'
,
$retryAfter
=
60
)
public
function
__construct
(
Connection
$database
,
$table
,
$default
=
'default'
,
$retryAfter
=
60
)
{
{
...
@@ -31,7 +31,7 @@ class MongoQueue extends DatabaseQueue
...
@@ -31,7 +31,7 @@ class MongoQueue extends DatabaseQueue
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
pop
(
$queue
=
null
)
public
function
pop
(
$queue
=
null
)
{
{
...
@@ -125,7 +125,7 @@ class MongoQueue extends DatabaseQueue
...
@@ -125,7 +125,7 @@ class MongoQueue extends DatabaseQueue
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
deleteReserved
(
$queue
,
$id
)
public
function
deleteReserved
(
$queue
,
$id
)
{
{
...
...
src/Jenssegers/Mongodb/Relations/BelongsTo.php
View file @
b379bd39
...
@@ -17,7 +17,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
...
@@ -17,7 +17,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
addConstraints
()
public
function
addConstraints
()
{
{
...
@@ -30,7 +30,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
...
@@ -30,7 +30,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
addEagerConstraints
(
array
$models
)
public
function
addEagerConstraints
(
array
$models
)
{
{
...
@@ -43,7 +43,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
...
@@ -43,7 +43,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
{
{
...
...
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
View file @
b379bd39
...
@@ -21,7 +21,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -21,7 +21,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
{
{
...
@@ -29,7 +29,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -29,7 +29,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
hydratePivotRelation
(
array
$models
)
protected
function
hydratePivotRelation
(
array
$models
)
{
{
...
@@ -47,7 +47,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -47,7 +47,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
shouldSelect
(
array
$columns
=
[
'*'
])
protected
function
shouldSelect
(
array
$columns
=
[
'*'
])
{
{
...
@@ -55,7 +55,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -55,7 +55,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
addConstraints
()
public
function
addConstraints
()
{
{
...
@@ -78,7 +78,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -78,7 +78,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
save
(
Model
$model
,
array
$joining
=
[],
$touch
=
true
)
public
function
save
(
Model
$model
,
array
$joining
=
[],
$touch
=
true
)
{
{
...
@@ -90,7 +90,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -90,7 +90,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
create
(
array
$attributes
=
[],
array
$joining
=
[],
$touch
=
true
)
public
function
create
(
array
$attributes
=
[],
array
$joining
=
[],
$touch
=
true
)
{
{
...
@@ -107,7 +107,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -107,7 +107,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
sync
(
$ids
,
$detaching
=
true
)
public
function
sync
(
$ids
,
$detaching
=
true
)
{
{
...
@@ -167,7 +167,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -167,7 +167,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
updateExistingPivot
(
$id
,
array
$attributes
,
$touch
=
true
)
public
function
updateExistingPivot
(
$id
,
array
$attributes
,
$touch
=
true
)
{
{
...
@@ -175,7 +175,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -175,7 +175,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
attach
(
$id
,
array
$attributes
=
[],
$touch
=
true
)
public
function
attach
(
$id
,
array
$attributes
=
[],
$touch
=
true
)
{
{
...
@@ -208,7 +208,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -208,7 +208,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
detach
(
$ids
=
[],
$touch
=
true
)
public
function
detach
(
$ids
=
[],
$touch
=
true
)
{
{
...
@@ -242,7 +242,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -242,7 +242,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
buildDictionary
(
Collection
$results
)
protected
function
buildDictionary
(
Collection
$results
)
{
{
...
@@ -263,7 +263,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -263,7 +263,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
newPivotQuery
()
public
function
newPivotQuery
()
{
{
...
@@ -289,7 +289,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -289,7 +289,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getQualifiedForeignPivotKeyName
()
public
function
getQualifiedForeignPivotKeyName
()
{
{
...
@@ -297,7 +297,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -297,7 +297,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getQualifiedRelatedPivotKeyName
()
public
function
getQualifiedRelatedPivotKeyName
()
{
{
...
@@ -306,7 +306,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -306,7 +306,7 @@ class BelongsToMany extends EloquentBelongsToMany
/**
/**
* Format the sync list so that it is keyed by ID. (Legacy Support)
* Format the sync list so that it is keyed by ID. (Legacy Support)
* The original function has been renamed to formatRecordsList since Laravel 5.3
* The original function has been renamed to formatRecordsList since Laravel 5.3
.
* @param array $records
* @param array $records
* @return array
* @return array
* @deprecated
* @deprecated
...
@@ -315,11 +315,12 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -315,11 +315,12 @@ class BelongsToMany extends EloquentBelongsToMany
{
{
$results
=
[];
$results
=
[];
foreach
(
$records
as
$id
=>
$attributes
)
{
foreach
(
$records
as
$id
=>
$attributes
)
{
if
(
!
is_array
(
$attributes
))
{
if
(
!
is_array
(
$attributes
))
{
list
(
$id
,
$attributes
)
=
[
$attributes
,
[]];
[
$id
,
$attributes
]
=
[
$attributes
,
[]];
}
}
$results
[
$id
]
=
$attributes
;
$results
[
$id
]
=
$attributes
;
}
}
return
$results
;
return
$results
;
}
}
...
...
src/Jenssegers/Mongodb/Relations/HasMany.php
View file @
b379bd39
...
@@ -36,7 +36,7 @@ class HasMany extends EloquentHasMany
...
@@ -36,7 +36,7 @@ class HasMany extends EloquentHasMany
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
{
{
...
...
src/Jenssegers/Mongodb/Relations/HasOne.php
View file @
b379bd39
...
@@ -36,7 +36,7 @@ class HasOne extends EloquentHasOne
...
@@ -36,7 +36,7 @@ class HasOne extends EloquentHasOne
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
{
{
...
...
src/Jenssegers/Mongodb/Relations/MorphTo.php
View file @
b379bd39
...
@@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo;
...
@@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo;
class
MorphTo
extends
EloquentMorphTo
class
MorphTo
extends
EloquentMorphTo
{
{
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
addConstraints
()
public
function
addConstraints
()
{
{
...
@@ -21,7 +21,7 @@ class MorphTo extends EloquentMorphTo
...
@@ -21,7 +21,7 @@ class MorphTo extends EloquentMorphTo
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
getResultsByType
(
$type
)
protected
function
getResultsByType
(
$type
)
{
{
...
...
src/Jenssegers/Mongodb/Schema/Blueprint.php
View file @
b379bd39
...
@@ -25,7 +25,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -25,7 +25,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
protected
$columns
=
[];
protected
$columns
=
[];
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
__construct
(
Connection
$connection
,
$collection
)
public
function
__construct
(
Connection
$connection
,
$collection
)
{
{
...
@@ -35,7 +35,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -35,7 +35,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
index
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
public
function
index
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
{
{
...
@@ -63,7 +63,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -63,7 +63,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
primary
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
public
function
primary
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
{
{
...
@@ -71,7 +71,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -71,7 +71,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
dropIndex
(
$indexOrColumns
=
null
)
public
function
dropIndex
(
$indexOrColumns
=
null
)
{
{
...
@@ -93,6 +93,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -93,6 +93,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
if
(
$this
->
hasIndex
(
$indexOrColumns
))
{
if
(
$this
->
hasIndex
(
$indexOrColumns
))
{
$this
->
dropIndex
(
$indexOrColumns
);
$this
->
dropIndex
(
$indexOrColumns
);
}
}
return
$this
;
return
$this
;
}
}
...
@@ -114,6 +115,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -114,6 +115,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
return
true
;
return
true
;
}
}
}
}
return
false
;
return
false
;
}
}
...
@@ -140,16 +142,17 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -140,16 +142,17 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
$sorting
=
$value
;
$sorting
=
$value
;
}
}
$transform
[
$column
]
=
$column
.
"_"
.
$sorting
;
$transform
[
$column
]
=
$column
.
'_'
.
$sorting
;
}
}
$indexOrColumns
=
implode
(
'_'
,
$transform
);
$indexOrColumns
=
implode
(
'_'
,
$transform
);
}
}
return
$indexOrColumns
;
return
$indexOrColumns
;
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
unique
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
public
function
unique
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
{
{
...
@@ -249,7 +252,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -249,7 +252,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
drop
()
public
function
drop
()
{
{
...
@@ -257,7 +260,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
...
@@ -257,7 +260,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
addColumn
(
$type
,
$name
,
array
$parameters
=
[])
public
function
addColumn
(
$type
,
$name
,
array
$parameters
=
[])
{
{
...
...
src/Jenssegers/Mongodb/Schema/Builder.php
View file @
b379bd39
...
@@ -8,7 +8,7 @@ use Jenssegers\Mongodb\Connection;
...
@@ -8,7 +8,7 @@ use Jenssegers\Mongodb\Connection;
class
Builder
extends
\Illuminate\Database\Schema\Builder
class
Builder
extends
\Illuminate\Database\Schema\Builder
{
{
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
__construct
(
Connection
$connection
)
public
function
__construct
(
Connection
$connection
)
{
{
...
@@ -16,7 +16,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -16,7 +16,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
hasColumn
(
$table
,
$column
)
public
function
hasColumn
(
$table
,
$column
)
{
{
...
@@ -24,7 +24,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -24,7 +24,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
hasColumns
(
$table
,
array
$columns
)
public
function
hasColumns
(
$table
,
array
$columns
)
{
{
...
@@ -50,7 +50,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -50,7 +50,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
hasTable
(
$collection
)
public
function
hasTable
(
$collection
)
{
{
...
@@ -73,7 +73,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -73,7 +73,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
table
(
$collection
,
Closure
$callback
)
public
function
table
(
$collection
,
Closure
$callback
)
{
{
...
@@ -81,7 +81,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -81,7 +81,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
create
(
$collection
,
Closure
$callback
=
null
,
array
$options
=
[])
public
function
create
(
$collection
,
Closure
$callback
=
null
,
array
$options
=
[])
{
{
...
@@ -95,7 +95,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -95,7 +95,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
dropIfExists
(
$collection
)
public
function
dropIfExists
(
$collection
)
{
{
...
@@ -107,7 +107,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -107,7 +107,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
drop
(
$collection
)
public
function
drop
(
$collection
)
{
{
...
@@ -117,7 +117,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -117,7 +117,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
public
function
dropAllTables
()
public
function
dropAllTables
()
{
{
...
@@ -127,7 +127,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
...
@@ -127,7 +127,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
}
/**
/**
*
@inheritdoc
*
{@inheritdoc}
*/
*/
protected
function
createBlueprint
(
$collection
,
Closure
$callback
=
null
)
protected
function
createBlueprint
(
$collection
,
Closure
$callback
=
null
)
{
{
...
...
src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php
View file @
b379bd39
...
@@ -40,7 +40,7 @@ class DatabasePresenceVerifier extends \Illuminate\Validation\DatabasePresenceVe
...
@@ -40,7 +40,7 @@ class DatabasePresenceVerifier extends \Illuminate\Validation\DatabasePresenceVe
public
function
getMultiCount
(
$collection
,
$column
,
array
$values
,
array
$extra
=
[])
public
function
getMultiCount
(
$collection
,
$column
,
array
$values
,
array
$extra
=
[])
{
{
// Generates a regex like '/(a|b|c)/i' which can query multiple values
// Generates a regex like '/(a|b|c)/i' which can query multiple values
$regex
=
'/('
.
implode
(
'|'
,
$values
)
.
')/i'
;
$regex
=
'/('
.
implode
(
'|'
,
$values
)
.
')/i'
;
$query
=
$this
->
table
(
$collection
)
->
where
(
$column
,
'regex'
,
$regex
);
$query
=
$this
->
table
(
$collection
)
->
where
(
$column
,
'regex'
,
$regex
);
...
...
tests/AuthTest.php
View file @
b379bd39
...
@@ -29,6 +29,7 @@ class AuthTest extends TestCase
...
@@ -29,6 +29,7 @@ class AuthTest extends TestCase
{
{
if
(
Application
::
VERSION
>=
'5.2'
)
{
if
(
Application
::
VERSION
>=
'5.2'
)
{
$this
->
expectNotToPerformAssertions
();
$this
->
expectNotToPerformAssertions
();
return
;
return
;
}
}
...
...
tests/CollectionTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Collection
;
use
Jenssegers\Mongodb\Collection
;
...
...
tests/ConnectionTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
...
@@ -97,7 +98,7 @@ class ConnectionTest extends TestCase
...
@@ -97,7 +98,7 @@ class ConnectionTest extends TestCase
Config
::
set
(
'database.connections.mongodb.options.database'
,
'custom'
);
Config
::
set
(
'database.connections.mongodb.options.database'
,
'custom'
);
$connection
=
DB
::
connection
(
'mongodb'
);
$connection
=
DB
::
connection
(
'mongodb'
);
$this
->
assertEquals
(
'mongodb://'
.
$host
.
'/custom'
,
(
string
)
$connection
->
getMongoClient
());
$this
->
assertEquals
(
'mongodb://'
.
$host
.
'/custom'
,
(
string
)
$connection
->
getMongoClient
());
}
}
public
function
testCustomHostAndPort
()
public
function
testCustomHostAndPort
()
...
@@ -106,7 +107,7 @@ class ConnectionTest extends TestCase
...
@@ -106,7 +107,7 @@ class ConnectionTest extends TestCase
Config
::
set
(
'database.connections.mongodb.port'
,
27000
);
Config
::
set
(
'database.connections.mongodb.port'
,
27000
);
$connection
=
DB
::
connection
(
'mongodb'
);
$connection
=
DB
::
connection
(
'mongodb'
);
$this
->
assertEquals
(
"mongodb://db1:27000"
,
(
string
)
$connection
->
getMongoClient
());
$this
->
assertEquals
(
'mongodb://db1:27000'
,
(
string
)
$connection
->
getMongoClient
());
}
}
public
function
testHostWithPorts
()
public
function
testHostWithPorts
()
...
...
tests/DsnTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
class
DsnTest
extends
TestCase
class
DsnTest
extends
TestCase
...
...
tests/GeospatialTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
class
GeospatialTest
extends
TestCase
class
GeospatialTest
extends
TestCase
...
...
tests/HybridRelationsTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\MySqlConnection
;
use
Illuminate\Database\MySqlConnection
;
...
@@ -28,7 +29,7 @@ class HybridRelationsTest extends TestCase
...
@@ -28,7 +29,7 @@ class HybridRelationsTest extends TestCase
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$user
->
getConnection
());
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$user
->
getConnection
());
// Mysql User
// Mysql User
$user
->
name
=
"John Doe"
;
$user
->
name
=
'John Doe'
;
$user
->
save
();
$user
->
save
();
$this
->
assertIsInt
(
$user
->
id
);
$this
->
assertIsInt
(
$user
->
id
);
...
@@ -54,7 +55,7 @@ class HybridRelationsTest extends TestCase
...
@@ -54,7 +55,7 @@ class HybridRelationsTest extends TestCase
// MongoDB User
// MongoDB User
$user
=
new
User
;
$user
=
new
User
;
$user
->
name
=
"John Doe"
;
$user
->
name
=
'John Doe'
;
$user
->
save
();
$user
->
save
();
// MongoDB has many
// MongoDB has many
...
@@ -88,7 +89,7 @@ class HybridRelationsTest extends TestCase
...
@@ -88,7 +89,7 @@ class HybridRelationsTest extends TestCase
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$otherUser
->
getConnection
());
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$otherUser
->
getConnection
());
//MySql User
//MySql User
$user
->
name
=
"John Doe"
;
$user
->
name
=
'John Doe'
;
$user
->
id
=
2
;
$user
->
id
=
2
;
$user
->
save
();
$user
->
save
();
// Other user
// Other user
...
@@ -142,7 +143,7 @@ class HybridRelationsTest extends TestCase
...
@@ -142,7 +143,7 @@ class HybridRelationsTest extends TestCase
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$otherUser
->
getConnection
());
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$otherUser
->
getConnection
());
//MySql User
//MySql User
$user
->
name
=
"John Doe"
;
$user
->
name
=
'John Doe'
;
$user
->
id
=
2
;
$user
->
id
=
2
;
$user
->
save
();
$user
->
save
();
// Other user
// Other user
...
...
tests/ModelTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Carbon\Carbon
;
use
Carbon\Carbon
;
...
...
tests/QueryBuilderTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Support\Facades\Date
;
use
Illuminate\Support\Facades\Date
;
...
@@ -545,22 +546,22 @@ class QueryBuilderTest extends TestCase
...
@@ -545,22 +546,22 @@ class QueryBuilderTest extends TestCase
public
function
testDates
()
public
function
testDates
()
{
{
DB
::
collection
(
'users'
)
->
insert
([
DB
::
collection
(
'users'
)
->
insert
([
[
'name'
=>
'John Doe'
,
'birthday'
=>
new
UTCDateTime
(
Date
::
parse
(
"1980-01-01 00:00:00"
)
->
format
(
'Uv'
))],
[
'name'
=>
'John Doe'
,
'birthday'
=>
new
UTCDateTime
(
Date
::
parse
(
'1980-01-01 00:00:00'
)
->
format
(
'Uv'
))],
[
'name'
=>
'Jane Doe'
,
'birthday'
=>
new
UTCDateTime
(
Date
::
parse
(
"1981-01-01 00:00:00"
)
->
format
(
'Uv'
))],
[
'name'
=>
'Jane Doe'
,
'birthday'
=>
new
UTCDateTime
(
Date
::
parse
(
'1981-01-01 00:00:00'
)
->
format
(
'Uv'
))],
[
'name'
=>
'Robert Roe'
,
'birthday'
=>
new
UTCDateTime
(
Date
::
parse
(
"1982-01-01 00:00:00"
)
->
format
(
'Uv'
))],
[
'name'
=>
'Robert Roe'
,
'birthday'
=>
new
UTCDateTime
(
Date
::
parse
(
'1982-01-01 00:00:00'
)
->
format
(
'Uv'
))],
[
'name'
=>
'Mark Moe'
,
'birthday'
=>
new
UTCDateTime
(
Date
::
parse
(
"1983-01-01 00:00:00"
)
->
format
(
'Uv'
))],
[
'name'
=>
'Mark Moe'
,
'birthday'
=>
new
UTCDateTime
(
Date
::
parse
(
'1983-01-01 00:00:00'
)
->
format
(
'Uv'
))],
]);
]);
$user
=
DB
::
collection
(
'users'
)
$user
=
DB
::
collection
(
'users'
)
->
where
(
'birthday'
,
new
UTCDateTime
(
Date
::
parse
(
"1980-01-01 00:00:00"
)
->
format
(
'Uv'
)))
->
where
(
'birthday'
,
new
UTCDateTime
(
Date
::
parse
(
'1980-01-01 00:00:00'
)
->
format
(
'Uv'
)))
->
first
();
->
first
();
$this
->
assertEquals
(
'John Doe'
,
$user
[
'name'
]);
$this
->
assertEquals
(
'John Doe'
,
$user
[
'name'
]);
$user
=
DB
::
collection
(
'users'
)
->
where
(
'birthday'
,
'='
,
new
DateTime
(
"1980-01-01 00:00:00"
))
->
first
();
$user
=
DB
::
collection
(
'users'
)
->
where
(
'birthday'
,
'='
,
new
DateTime
(
'1980-01-01 00:00:00'
))
->
first
();
$this
->
assertEquals
(
'John Doe'
,
$user
[
'name'
]);
$this
->
assertEquals
(
'John Doe'
,
$user
[
'name'
]);
$start
=
new
UTCDateTime
(
1000
*
strtotime
(
"1981-01-01 00:00:00"
));
$start
=
new
UTCDateTime
(
1000
*
strtotime
(
'1981-01-01 00:00:00'
));
$stop
=
new
UTCDateTime
(
1000
*
strtotime
(
"1982-01-01 00:00:00"
));
$stop
=
new
UTCDateTime
(
1000
*
strtotime
(
'1982-01-01 00:00:00'
));
$users
=
DB
::
collection
(
'users'
)
->
whereBetween
(
'birthday'
,
[
$start
,
$stop
])
->
get
();
$users
=
DB
::
collection
(
'users'
)
->
whereBetween
(
'birthday'
,
[
$start
,
$stop
])
->
get
();
$this
->
assertCount
(
2
,
$users
);
$this
->
assertCount
(
2
,
$users
);
...
@@ -623,11 +624,11 @@ class QueryBuilderTest extends TestCase
...
@@ -623,11 +624,11 @@ class QueryBuilderTest extends TestCase
$results
=
DB
::
collection
(
'items'
)
->
where
(
'tags'
,
'size'
,
4
)
->
get
();
$results
=
DB
::
collection
(
'items'
)
->
where
(
'tags'
,
'size'
,
4
)
->
get
();
$this
->
assertCount
(
1
,
$results
);
$this
->
assertCount
(
1
,
$results
);
$regex
=
new
Regex
(
".*doe"
,
"i"
);
$regex
=
new
Regex
(
'.*doe'
,
'i'
);
$results
=
DB
::
collection
(
'users'
)
->
where
(
'name'
,
'regex'
,
$regex
)
->
get
();
$results
=
DB
::
collection
(
'users'
)
->
where
(
'name'
,
'regex'
,
$regex
)
->
get
();
$this
->
assertCount
(
2
,
$results
);
$this
->
assertCount
(
2
,
$results
);
$regex
=
new
Regex
(
".*doe"
,
"i"
);
$regex
=
new
Regex
(
'.*doe'
,
'i'
);
$results
=
DB
::
collection
(
'users'
)
->
where
(
'name'
,
'regexp'
,
$regex
)
->
get
();
$results
=
DB
::
collection
(
'users'
)
->
where
(
'name'
,
'regexp'
,
$regex
)
->
get
();
$this
->
assertCount
(
2
,
$results
);
$this
->
assertCount
(
2
,
$results
);
...
...
tests/QueryTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
class
QueryTest
extends
TestCase
class
QueryTest
extends
TestCase
...
...
tests/QueueTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Carbon\Carbon
;
use
Carbon\Carbon
;
...
...
tests/RelationsTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Collection
;
use
Illuminate\Database\Eloquent\Collection
;
...
...
tests/SchemaTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Schema\Blueprint
;
use
Jenssegers\Mongodb\Schema\Blueprint
;
...
...
tests/SeederTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
class
SeederTest
extends
TestCase
class
SeederTest
extends
TestCase
...
...
tests/TestCase.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Auth\Passwords\PasswordResetServiceProvider
;
use
Illuminate\Auth\Passwords\PasswordResetServiceProvider
;
...
...
tests/ValidationTest.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
class
ValidationTest
extends
TestCase
class
ValidationTest
extends
TestCase
...
...
tests/config/database.php
View file @
b379bd39
...
@@ -23,7 +23,7 @@ return [
...
@@ -23,7 +23,7 @@ return [
'dsn_mongodb_db'
=>
[
'dsn_mongodb_db'
=>
[
'driver'
=>
'mongodb'
,
'driver'
=>
'mongodb'
,
'dsn'
=>
"mongodb://
$mongoHost
:
$mongoPort
/"
.
env
(
'MONGO_DATABASE'
,
'unittest'
),
'dsn'
=>
"mongodb://
$mongoHost
:
$mongoPort
/"
.
env
(
'MONGO_DATABASE'
,
'unittest'
),
],
],
'mysql'
=>
[
'mysql'
=>
[
...
...
tests/models/Address.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
...
...
tests/models/Book.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
/**
/**
* Class Book
* Class Book
.
* @property string $title
* @property string $title
* @property string $author
* @property string $author
* @property array $chapters
* @property array $chapters
...
...
tests/models/Client.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsToMany
;
use
Illuminate\Database\Eloquent\Relations\BelongsToMany
;
...
...
tests/models/Group.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsToMany
;
use
Illuminate\Database\Eloquent\Relations\BelongsToMany
;
...
...
tests/models/Item.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
...
@@ -6,7 +7,7 @@ use Jenssegers\Mongodb\Eloquent\Builder;
...
@@ -6,7 +7,7 @@ use Jenssegers\Mongodb\Eloquent\Builder;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
/**
/**
* Class Item
* Class Item
.
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $created_at
*/
*/
class
Item
extends
Eloquent
class
Item
extends
Eloquent
...
...
tests/models/Location.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
...
...
tests/models/MysqlBook.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
...
@@ -28,7 +29,7 @@ class MysqlBook extends Eloquent
...
@@ -28,7 +29,7 @@ class MysqlBook extends Eloquent
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
$schema
=
Schema
::
connection
(
'mysql'
);
$schema
=
Schema
::
connection
(
'mysql'
);
if
(
!
$schema
->
hasTable
(
'books'
))
{
if
(
!
$schema
->
hasTable
(
'books'
))
{
Schema
::
connection
(
'mysql'
)
->
create
(
'books'
,
function
(
Blueprint
$table
)
{
Schema
::
connection
(
'mysql'
)
->
create
(
'books'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'title'
);
$table
->
string
(
'title'
);
$table
->
string
(
'author_id'
)
->
nullable
();
$table
->
string
(
'author_id'
)
->
nullable
();
...
...
tests/models/MysqlRole.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
...
@@ -32,7 +33,7 @@ class MysqlRole extends Eloquent
...
@@ -32,7 +33,7 @@ class MysqlRole extends Eloquent
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
$schema
=
Schema
::
connection
(
'mysql'
);
$schema
=
Schema
::
connection
(
'mysql'
);
if
(
!
$schema
->
hasTable
(
'roles'
))
{
if
(
!
$schema
->
hasTable
(
'roles'
))
{
Schema
::
connection
(
'mysql'
)
->
create
(
'roles'
,
function
(
Blueprint
$table
)
{
Schema
::
connection
(
'mysql'
)
->
create
(
'roles'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'type'
);
$table
->
string
(
'type'
);
$table
->
string
(
'user_id'
);
$table
->
string
(
'user_id'
);
...
...
tests/models/MysqlUser.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
...
@@ -38,7 +39,7 @@ class MysqlUser extends Eloquent
...
@@ -38,7 +39,7 @@ class MysqlUser extends Eloquent
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
$schema
=
Schema
::
connection
(
'mysql'
);
$schema
=
Schema
::
connection
(
'mysql'
);
if
(
!
$schema
->
hasTable
(
'users'
))
{
if
(
!
$schema
->
hasTable
(
'users'
))
{
Schema
::
connection
(
'mysql'
)
->
create
(
'users'
,
function
(
Blueprint
$table
)
{
Schema
::
connection
(
'mysql'
)
->
create
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
increments
(
'id'
);
$table
->
increments
(
'id'
);
$table
->
string
(
'name'
);
$table
->
string
(
'name'
);
...
...
tests/models/Photo.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\MorphTo
;
use
Illuminate\Database\Eloquent\Relations\MorphTo
;
...
...
tests/models/Role.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
...
...
tests/models/Scoped.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Eloquent\Builder
;
use
Jenssegers\Mongodb\Eloquent\Builder
;
...
...
tests/models/Soft.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\SoftDeletes
;
use
Jenssegers\Mongodb\Eloquent\SoftDeletes
;
/**
/**
* Class Soft
* Class Soft
.
* @property \Carbon\Carbon $deleted_at
* @property \Carbon\Carbon $deleted_at
*/
*/
class
Soft
extends
Eloquent
class
Soft
extends
Eloquent
...
...
tests/models/User.php
View file @
b379bd39
<?php
<?php
declare
(
strict_types
=
1
);
declare
(
strict_types
=
1
);
use
Illuminate\Auth\Authenticatable
;
use
Illuminate\Auth\Authenticatable
;
...
@@ -10,7 +11,7 @@ use Jenssegers\Mongodb\Eloquent\HybridRelations;
...
@@ -10,7 +11,7 @@ use Jenssegers\Mongodb\Eloquent\HybridRelations;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
/**
/**
* Class User
* Class User
.
* @property string $_id
* @property string $_id
* @property string $name
* @property string $name
* @property string $title
* @property string $title
...
...
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