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
56b874de
Commit
56b874de
authored
Mar 05, 2020
by
Divine
Committed by
StyleCI Bot
Mar 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply fixes from StyleCI
parent
444e90df
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 @
56b874de
...
...
@@ -11,7 +11,7 @@ use MongoDB\BSON\UTCDateTime;
class
DatabaseTokenRepository
extends
BaseDatabaseTokenRepository
{
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
getPayload
(
$email
,
$token
)
{
...
...
@@ -23,7 +23,7 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
tokenExpired
(
$createdAt
)
{
...
...
@@ -33,7 +33,7 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
tokenRecentlyCreated
(
$createdAt
)
{
...
...
src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php
View file @
56b874de
...
...
@@ -7,7 +7,7 @@ use Illuminate\Auth\Passwords\PasswordBrokerManager as BasePasswordBrokerManager
class
PasswordBrokerManager
extends
BasePasswordBrokerManager
{
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
createTokenRepository
(
array
$config
)
{
...
...
src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php
View file @
56b874de
...
...
@@ -29,7 +29,7 @@ class PasswordResetServiceProvider extends BasePasswordResetServiceProvider
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
registerPasswordBroker
()
{
...
...
src/Jenssegers/Mongodb/Collection.php
View file @
56b874de
...
...
@@ -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
);
}
...
...
src/Jenssegers/Mongodb/Connection.php
View file @
56b874de
...
...
@@ -85,7 +85,7 @@ class Connection extends BaseConnection
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getSchemaBuilder
()
{
...
...
@@ -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 array $config
* @return string
...
...
@@ -131,7 +131,7 @@ class Connection extends BaseConnection
if
(
preg_match
(
'/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s'
,
$dsn
,
$matches
))
{
$config
[
'database'
]
=
$matches
[
1
];
}
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
}
// 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'
];
}
if
(
!
isset
(
$options
[
'password'
])
&&
!
empty
(
$config
[
'password'
]))
{
if
(
!
isset
(
$options
[
'password'
])
&&
!
empty
(
$config
[
'password'
]))
{
$options
[
'password'
]
=
$config
[
'password'
];
}
...
...
@@ -166,7 +166,7 @@ class Connection extends BaseConnection
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
disconnect
()
{
...
...
@@ -180,7 +180,7 @@ class Connection extends BaseConnection
*/
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
foreach
(
$hosts
as
&
$host
)
{
// Check if we need to add a port to the host
if
(
strpos
(
$host
,
':'
)
===
false
&&
!
empty
(
$config
[
'port'
]))
{
$host
=
$host
.
':'
.
$config
[
'port'
];
if
(
strpos
(
$host
,
':'
)
===
false
&&
!
empty
(
$config
[
'port'
]))
{
$host
=
$host
.
':'
.
$config
[
'port'
];
}
}
// Check if we want to authenticate against a specific database.
$auth_database
=
isset
(
$config
[
'options'
])
&&
!
empty
(
$config
[
'options'
][
'database'
])
?
$config
[
'options'
][
'database'
]
:
null
;
return
'mongodb://'
.
implode
(
','
,
$hosts
)
.
(
$auth_database
?
'/'
.
$auth_database
:
''
);
$auth_database
=
isset
(
$config
[
'options'
])
&&
!
empty
(
$config
[
'options'
][
'database'
])
?
$config
[
'options'
][
'database'
]
:
null
;
return
'mongodb://'
.
implode
(
','
,
$hosts
)
.
(
$auth_database
?
'/'
.
$auth_database
:
''
);
}
/**
...
...
@@ -228,7 +229,7 @@ class Connection extends BaseConnection
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getElapsedTime
(
$start
)
{
...
...
@@ -236,7 +237,7 @@ class Connection extends BaseConnection
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getDriverName
()
{
...
...
@@ -244,7 +245,7 @@ class Connection extends BaseConnection
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
getDefaultPostProcessor
()
{
...
...
@@ -252,7 +253,7 @@ class Connection extends BaseConnection
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
getDefaultQueryGrammar
()
{
...
...
@@ -260,7 +261,7 @@ class Connection extends BaseConnection
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
getDefaultSchemaGrammar
()
{
...
...
src/Jenssegers/Mongodb/Eloquent/Builder.php
View file @
56b874de
...
...
@@ -31,7 +31,7 @@ class Builder extends EloquentBuilder
];
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
update
(
array
$values
,
array
$options
=
[])
{
...
...
@@ -39,7 +39,7 @@ class Builder extends EloquentBuilder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
insert
(
array
$values
)
{
...
...
@@ -47,7 +47,7 @@ class Builder extends EloquentBuilder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
insertGetId
(
array
$values
,
$sequence
=
null
)
{
...
...
@@ -55,7 +55,7 @@ class Builder extends EloquentBuilder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
delete
()
{
...
...
@@ -63,7 +63,7 @@ class Builder extends EloquentBuilder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
increment
(
$column
,
$amount
=
1
,
array
$extra
=
[])
{
...
...
@@ -71,7 +71,7 @@ class Builder extends EloquentBuilder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
decrement
(
$column
,
$amount
=
1
,
array
$extra
=
[])
{
...
...
@@ -79,7 +79,7 @@ class Builder extends EloquentBuilder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
chunkById
(
$count
,
callable
$callback
,
$column
=
'_id'
,
$alias
=
null
)
{
...
...
@@ -87,7 +87,7 @@ class Builder extends EloquentBuilder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
raw
(
$expression
=
null
)
{
...
...
@@ -116,13 +116,13 @@ class Builder extends EloquentBuilder
* Add the "updated at" column to an array of values.
* TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e
* 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
* @return array
*/
protected
function
addUpdatedAtColumn
(
array
$values
)
{
if
(
!
$this
->
model
->
usesTimestamps
()
||
$this
->
model
->
getUpdatedAtColumn
()
===
null
)
{
if
(
!
$this
->
model
->
usesTimestamps
()
||
$this
->
model
->
getUpdatedAtColumn
()
===
null
)
{
return
$values
;
}
...
...
src/Jenssegers/Mongodb/Eloquent/HybridRelations.php
View file @
56b874de
...
...
@@ -9,8 +9,8 @@ use Jenssegers\Mongodb\Relations\BelongsTo;
use
Jenssegers\Mongodb\Relations\BelongsToMany
;
use
Jenssegers\Mongodb\Relations\HasMany
;
use
Jenssegers\Mongodb\Relations\HasOne
;
use
Jenssegers\Mongodb\Relations\MorphTo
;
use
Jenssegers\Mongodb\Relations\MorphMany
;
use
Jenssegers\Mongodb\Relations\MorphTo
;
trait
HybridRelations
{
...
...
@@ -24,7 +24,7 @@ trait HybridRelations
public
function
hasOne
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
{
// 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
);
}
...
...
@@ -49,13 +49,13 @@ trait HybridRelations
public
function
morphOne
(
$related
,
$name
,
$type
=
null
,
$id
=
null
,
$localKey
=
null
)
{
// 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
);
}
$instance
=
new
$related
;
list
(
$type
,
$id
)
=
$this
->
getMorphs
(
$name
,
$type
,
$id
);
[
$type
,
$id
]
=
$this
->
getMorphs
(
$name
,
$type
,
$id
);
$localKey
=
$localKey
?:
$this
->
getKeyName
();
...
...
@@ -72,7 +72,7 @@ trait HybridRelations
public
function
hasMany
(
$related
,
$foreignKey
=
null
,
$localKey
=
null
)
{
// 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
);
}
...
...
@@ -97,7 +97,7 @@ trait HybridRelations
public
function
morphMany
(
$related
,
$name
,
$type
=
null
,
$id
=
null
,
$localKey
=
null
)
{
// 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
);
}
...
...
@@ -106,7 +106,7 @@ trait HybridRelations
// 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
// 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
();
...
...
@@ -129,13 +129,13 @@ trait HybridRelations
// 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.
if
(
$relation
===
null
)
{
list
(
$current
,
$caller
)
=
debug_backtrace
(
false
,
2
);
[
$current
,
$caller
]
=
debug_backtrace
(
false
,
2
);
$relation
=
$caller
[
'function'
];
}
// 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
);
}
...
...
@@ -143,7 +143,7 @@ trait HybridRelations
// foreign key name by using the name of the relationship function, which
// when combined with an "_id" should conventionally match the columns.
if
(
$foreignKey
===
null
)
{
$foreignKey
=
Str
::
snake
(
$relation
)
.
'_id'
;
$foreignKey
=
Str
::
snake
(
$relation
)
.
'_id'
;
}
$instance
=
new
$related
;
...
...
@@ -172,12 +172,12 @@ trait HybridRelations
// 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.
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'
]);
}
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
// the relationship. When that is the case we will pass in a dummy query as
...
...
@@ -230,7 +230,7 @@ trait HybridRelations
}
// 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
(
$related
,
$collection
,
...
...
@@ -245,11 +245,11 @@ trait HybridRelations
// 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
// instances as well as the relationship instances we need for this.
$foreignKey
=
$foreignKey
?:
$this
->
getForeignKey
()
.
's'
;
$foreignKey
=
$foreignKey
?:
$this
->
getForeignKey
()
.
's'
;
$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
// models using underscores in alphabetical order. The two model names
...
...
@@ -289,7 +289,7 @@ trait HybridRelations
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
newEloquentBuilder
(
$query
)
{
...
...
src/Jenssegers/Mongodb/Eloquent/Model.php
View file @
56b874de
...
...
@@ -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.
// 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'
];
}
...
...
@@ -67,7 +67,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getQualifiedKeyName
()
{
...
...
@@ -75,7 +75,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
fromDateTime
(
$value
)
{
...
...
@@ -85,7 +85,7 @@ abstract class Model extends BaseModel
}
// Let Eloquent convert the value to a DateTime instance.
if
(
!
$value
instanceof
DateTime
)
{
if
(
!
$value
instanceof
DateTime
)
{
$value
=
parent
::
asDateTime
(
$value
);
}
...
...
@@ -93,7 +93,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
asDateTime
(
$value
)
{
...
...
@@ -106,7 +106,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getDateFormat
()
{
...
...
@@ -114,7 +114,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
freshTimestamp
()
{
...
...
@@ -122,7 +122,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getTable
()
{
...
...
@@ -130,11 +130,11 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getAttribute
(
$key
)
{
if
(
!
$key
)
{
if
(
!
$key
)
{
return
;
}
...
...
@@ -147,7 +147,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
getAttributeFromArray
(
$key
)
{
...
...
@@ -160,7 +160,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
setAttribute
(
$key
,
$value
)
{
...
...
@@ -184,7 +184,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
attributesToArray
()
{
...
...
@@ -213,7 +213,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getCasts
()
{
...
...
@@ -221,11 +221,11 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
originalIsEquivalent
(
$key
,
$current
)
{
if
(
!
array_key_exists
(
$key
,
$this
->
original
))
{
if
(
!
array_key_exists
(
$key
,
$this
->
original
))
{
return
false
;
}
...
...
@@ -274,7 +274,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
push
()
{
...
...
@@ -282,9 +282,9 @@ abstract class Model extends BaseModel
$unique
=
false
;
if
(
count
(
$parameters
)
===
3
)
{
list
(
$column
,
$values
,
$unique
)
=
$parameters
;
[
$column
,
$values
,
$unique
]
=
$parameters
;
}
else
{
list
(
$column
,
$values
)
=
$parameters
;
[
$column
,
$values
]
=
$parameters
;
}
// Do batch push by default.
...
...
@@ -330,7 +330,7 @@ abstract class Model extends BaseModel
foreach
(
$values
as
$value
)
{
// 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
;
}
...
...
@@ -367,11 +367,11 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
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
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
newEloquentBuilder
(
$query
)
{
...
...
@@ -401,7 +401,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
newBaseQueryBuilder
()
{
...
...
@@ -411,7 +411,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
removeTableFromKey
(
$key
)
{
...
...
@@ -433,13 +433,13 @@ abstract class Model extends BaseModel
if
(
$relation
instanceof
QueueableCollection
)
{
foreach
(
$relation
->
getQueueableRelations
()
as
$collectionValue
)
{
$relations
[]
=
$key
.
'.'
.
$collectionValue
;
$relations
[]
=
$key
.
'.'
.
$collectionValue
;
}
}
if
(
$relation
instanceof
QueueableEntity
)
{
foreach
(
$relation
->
getQueueableRelations
()
as
$entityKey
=>
$entityValue
)
{
$relations
[]
=
$key
.
'.'
.
$entityValue
;
$relations
[]
=
$key
.
'.'
.
$entityValue
;
}
}
}
...
...
@@ -463,7 +463,7 @@ abstract class Model extends BaseModel
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
__call
(
$method
,
$parameters
)
{
...
...
src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php
View file @
56b874de
...
...
@@ -7,7 +7,7 @@ trait SoftDeletes
use
\Illuminate\Database\Eloquent\SoftDeletes
;
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getQualifiedDeletedAtColumn
()
{
...
...
src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php
View file @
56b874de
...
...
@@ -71,7 +71,7 @@ trait QueriesRelationships
}
/**
* Compare across databases
* Compare across databases
.
* @param Relation $relation
* @param string $operator
* @param int $count
...
...
@@ -91,7 +91,7 @@ trait QueriesRelationships
$not
=
in_array
(
$operator
,
[
'<'
,
'<='
,
'!='
]);
// If we are comparing to 0, we need an additional $not flip.
if
(
$count
==
0
)
{
$not
=
!
$not
;
$not
=
!
$not
;
}
$relations
=
$hasQuery
->
pluck
(
$this
->
getHasCompareKey
(
$relation
));
...
...
@@ -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
* @return string
* @throws Exception
...
...
@@ -164,10 +164,10 @@ trait QueriesRelationships
return
$relation
->
getForeignKeyName
();
}
if
(
$relation
instanceof
BelongsToMany
&&
!
$this
->
isAcrossConnections
(
$relation
))
{
if
(
$relation
instanceof
BelongsToMany
&&
!
$this
->
isAcrossConnections
(
$relation
))
{
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 @
56b874de
...
...
@@ -2,14 +2,14 @@
namespace
Jenssegers\Mongodb
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Queue\QueueServiceProvider
;
use
Illuminate\Support\Facades\DB
;
use
Jenssegers\Mongodb\Queue\Failed\MongoFailedJobProvider
;
class
MongodbQueueServiceProvider
extends
QueueServiceProvider
{
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
registerFailedJobServices
()
{
...
...
src/Jenssegers/Mongodb/MongodbServiceProvider.php
View file @
56b874de
...
...
@@ -27,6 +27,7 @@ class MongodbServiceProvider extends ServiceProvider
$this
->
app
->
resolving
(
'db'
,
function
(
$db
)
{
$db
->
extend
(
'mongodb'
,
function
(
$config
,
$name
)
{
$config
[
'name'
]
=
$name
;
return
new
Connection
(
$config
);
});
});
...
...
src/Jenssegers/Mongodb/Query/Builder.php
View file @
56b874de
This diff is collapsed.
Click to expand it.
src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php
View file @
56b874de
...
...
@@ -34,6 +34,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
$all
=
array_map
(
function
(
$job
)
{
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
return
(
object
)
$job
;
},
$all
);
...
...
@@ -49,7 +50,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
{
$job
=
$this
->
getTable
()
->
find
(
$id
);
if
(
!
$job
)
{
if
(
!
$job
)
{
return
;
}
...
...
src/Jenssegers/Mongodb/Queue/MongoQueue.php
View file @
56b874de
...
...
@@ -22,7 +22,7 @@ class MongoQueue extends DatabaseQueue
protected
$connectionName
;
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
__construct
(
Connection
$database
,
$table
,
$default
=
'default'
,
$retryAfter
=
60
)
{
...
...
@@ -31,7 +31,7 @@ class MongoQueue extends DatabaseQueue
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
pop
(
$queue
=
null
)
{
...
...
@@ -125,7 +125,7 @@ class MongoQueue extends DatabaseQueue
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
deleteReserved
(
$queue
,
$id
)
{
...
...
src/Jenssegers/Mongodb/Relations/BelongsTo.php
View file @
56b874de
...
...
@@ -17,7 +17,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
addConstraints
()
{
...
...
@@ -30,7 +30,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
addEagerConstraints
(
array
$models
)
{
...
...
@@ -43,7 +43,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
{
...
...
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
View file @
56b874de
...
...
@@ -21,7 +21,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
{
...
...
@@ -29,7 +29,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
hydratePivotRelation
(
array
$models
)
{
...
...
@@ -47,7 +47,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
shouldSelect
(
array
$columns
=
[
'*'
])
{
...
...
@@ -55,7 +55,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
addConstraints
()
{
...
...
@@ -78,7 +78,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
save
(
Model
$model
,
array
$joining
=
[],
$touch
=
true
)
{
...
...
@@ -90,7 +90,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
create
(
array
$attributes
=
[],
array
$joining
=
[],
$touch
=
true
)
{
...
...
@@ -107,7 +107,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
sync
(
$ids
,
$detaching
=
true
)
{
...
...
@@ -167,7 +167,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
updateExistingPivot
(
$id
,
array
$attributes
,
$touch
=
true
)
{
...
...
@@ -175,7 +175,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
attach
(
$id
,
array
$attributes
=
[],
$touch
=
true
)
{
...
...
@@ -208,7 +208,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
detach
(
$ids
=
[],
$touch
=
true
)
{
...
...
@@ -242,7 +242,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
buildDictionary
(
Collection
$results
)
{
...
...
@@ -263,7 +263,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
newPivotQuery
()
{
...
...
@@ -289,7 +289,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getQualifiedForeignPivotKeyName
()
{
...
...
@@ -297,7 +297,7 @@ class BelongsToMany extends EloquentBelongsToMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getQualifiedRelatedPivotKeyName
()
{
...
...
@@ -306,7 +306,7 @@ class BelongsToMany extends EloquentBelongsToMany
/**
* 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
* @return array
* @deprecated
...
...
@@ -315,11 +315,12 @@ class BelongsToMany extends EloquentBelongsToMany
{
$results
=
[];
foreach
(
$records
as
$id
=>
$attributes
)
{
if
(
!
is_array
(
$attributes
))
{
list
(
$id
,
$attributes
)
=
[
$attributes
,
[]];
if
(
!
is_array
(
$attributes
))
{
[
$id
,
$attributes
]
=
[
$attributes
,
[]];
}
$results
[
$id
]
=
$attributes
;
}
return
$results
;
}
...
...
src/Jenssegers/Mongodb/Relations/HasMany.php
View file @
56b874de
...
...
@@ -36,7 +36,7 @@ class HasMany extends EloquentHasMany
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
{
...
...
src/Jenssegers/Mongodb/Relations/HasOne.php
View file @
56b874de
...
...
@@ -36,7 +36,7 @@ class HasOne extends EloquentHasOne
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
getRelationExistenceQuery
(
Builder
$query
,
Builder
$parentQuery
,
$columns
=
[
'*'
])
{
...
...
src/Jenssegers/Mongodb/Relations/MorphTo.php
View file @
56b874de
...
...
@@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo;
class
MorphTo
extends
EloquentMorphTo
{
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
addConstraints
()
{
...
...
@@ -21,7 +21,7 @@ class MorphTo extends EloquentMorphTo
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
getResultsByType
(
$type
)
{
...
...
src/Jenssegers/Mongodb/Schema/Blueprint.php
View file @
56b874de
...
...
@@ -25,7 +25,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
protected
$columns
=
[];
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
__construct
(
Connection
$connection
,
$collection
)
{
...
...
@@ -35,7 +35,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
index
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
{
...
...
@@ -63,7 +63,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
primary
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
{
...
...
@@ -71,7 +71,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
dropIndex
(
$indexOrColumns
=
null
)
{
...
...
@@ -93,6 +93,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
if
(
$this
->
hasIndex
(
$indexOrColumns
))
{
$this
->
dropIndex
(
$indexOrColumns
);
}
return
$this
;
}
...
...
@@ -114,6 +115,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
return
true
;
}
}
return
false
;
}
...
...
@@ -140,16 +142,17 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
$sorting
=
$value
;
}
$transform
[
$column
]
=
$column
.
"_"
.
$sorting
;
$transform
[
$column
]
=
$column
.
'_'
.
$sorting
;
}
$indexOrColumns
=
implode
(
'_'
,
$transform
);
}
return
$indexOrColumns
;
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
unique
(
$columns
=
null
,
$name
=
null
,
$algorithm
=
null
,
$options
=
[])
{
...
...
@@ -249,7 +252,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
drop
()
{
...
...
@@ -257,7 +260,7 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
addColumn
(
$type
,
$name
,
array
$parameters
=
[])
{
...
...
src/Jenssegers/Mongodb/Schema/Builder.php
View file @
56b874de
...
...
@@ -8,7 +8,7 @@ use Jenssegers\Mongodb\Connection;
class
Builder
extends
\Illuminate\Database\Schema\Builder
{
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
__construct
(
Connection
$connection
)
{
...
...
@@ -16,7 +16,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
hasColumn
(
$table
,
$column
)
{
...
...
@@ -24,7 +24,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
hasColumns
(
$table
,
array
$columns
)
{
...
...
@@ -50,7 +50,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
hasTable
(
$collection
)
{
...
...
@@ -73,7 +73,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
table
(
$collection
,
Closure
$callback
)
{
...
...
@@ -81,7 +81,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
create
(
$collection
,
Closure
$callback
=
null
,
array
$options
=
[])
{
...
...
@@ -95,7 +95,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
dropIfExists
(
$collection
)
{
...
...
@@ -107,7 +107,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
drop
(
$collection
)
{
...
...
@@ -117,7 +117,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
public
function
dropAllTables
()
{
...
...
@@ -127,7 +127,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
}
/**
*
@inheritdoc
*
{@inheritdoc}
*/
protected
function
createBlueprint
(
$collection
,
Closure
$callback
=
null
)
{
...
...
src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php
View file @
56b874de
...
...
@@ -40,7 +40,7 @@ class DatabasePresenceVerifier extends \Illuminate\Validation\DatabasePresenceVe
public
function
getMultiCount
(
$collection
,
$column
,
array
$values
,
array
$extra
=
[])
{
// 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
);
...
...
tests/AuthTest.php
View file @
56b874de
...
...
@@ -29,6 +29,7 @@ class AuthTest extends TestCase
{
if
(
Application
::
VERSION
>=
'5.2'
)
{
$this
->
expectNotToPerformAssertions
();
return
;
}
...
...
tests/CollectionTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Collection
;
...
...
tests/ConnectionTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Support\Facades\DB
;
...
...
@@ -97,7 +98,7 @@ class ConnectionTest extends TestCase
Config
::
set
(
'database.connections.mongodb.options.database'
,
'custom'
);
$connection
=
DB
::
connection
(
'mongodb'
);
$this
->
assertEquals
(
'mongodb://'
.
$host
.
'/custom'
,
(
string
)
$connection
->
getMongoClient
());
$this
->
assertEquals
(
'mongodb://'
.
$host
.
'/custom'
,
(
string
)
$connection
->
getMongoClient
());
}
public
function
testCustomHostAndPort
()
...
...
@@ -106,7 +107,7 @@ class ConnectionTest extends TestCase
Config
::
set
(
'database.connections.mongodb.port'
,
27000
);
$connection
=
DB
::
connection
(
'mongodb'
);
$this
->
assertEquals
(
"mongodb://db1:27000"
,
(
string
)
$connection
->
getMongoClient
());
$this
->
assertEquals
(
'mongodb://db1:27000'
,
(
string
)
$connection
->
getMongoClient
());
}
public
function
testHostWithPorts
()
...
...
tests/DsnTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
class
DsnTest
extends
TestCase
...
...
tests/GeospatialTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
class
GeospatialTest
extends
TestCase
...
...
tests/HybridRelationsTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\MySqlConnection
;
...
...
@@ -28,7 +29,7 @@ class HybridRelationsTest extends TestCase
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$user
->
getConnection
());
// Mysql User
$user
->
name
=
"John Doe"
;
$user
->
name
=
'John Doe'
;
$user
->
save
();
$this
->
assertIsInt
(
$user
->
id
);
...
...
@@ -54,7 +55,7 @@ class HybridRelationsTest extends TestCase
// MongoDB User
$user
=
new
User
;
$user
->
name
=
"John Doe"
;
$user
->
name
=
'John Doe'
;
$user
->
save
();
// MongoDB has many
...
...
@@ -88,7 +89,7 @@ class HybridRelationsTest extends TestCase
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$otherUser
->
getConnection
());
//MySql User
$user
->
name
=
"John Doe"
;
$user
->
name
=
'John Doe'
;
$user
->
id
=
2
;
$user
->
save
();
// Other user
...
...
@@ -142,7 +143,7 @@ class HybridRelationsTest extends TestCase
$this
->
assertInstanceOf
(
MySqlConnection
::
class
,
$otherUser
->
getConnection
());
//MySql User
$user
->
name
=
"John Doe"
;
$user
->
name
=
'John Doe'
;
$user
->
id
=
2
;
$user
->
save
();
// Other user
...
...
tests/ModelTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Carbon\Carbon
;
...
...
tests/QueryBuilderTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Support\Facades\Date
;
...
...
@@ -545,22 +546,22 @@ class QueryBuilderTest extends TestCase
public
function
testDates
()
{
DB
::
collection
(
'users'
)
->
insert
([
[
'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'
=>
'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'
=>
'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'
=>
'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'
))],
]);
$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
();
$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'
]);
$start
=
new
UTCDateTime
(
1000
*
strtotime
(
"1981-01-01 00:00:00"
));
$stop
=
new
UTCDateTime
(
1000
*
strtotime
(
"1982-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'
));
$users
=
DB
::
collection
(
'users'
)
->
whereBetween
(
'birthday'
,
[
$start
,
$stop
])
->
get
();
$this
->
assertCount
(
2
,
$users
);
...
...
@@ -623,11 +624,11 @@ class QueryBuilderTest extends TestCase
$results
=
DB
::
collection
(
'items'
)
->
where
(
'tags'
,
'size'
,
4
)
->
get
();
$this
->
assertCount
(
1
,
$results
);
$regex
=
new
Regex
(
".*doe"
,
"i"
);
$regex
=
new
Regex
(
'.*doe'
,
'i'
);
$results
=
DB
::
collection
(
'users'
)
->
where
(
'name'
,
'regex'
,
$regex
)
->
get
();
$this
->
assertCount
(
2
,
$results
);
$regex
=
new
Regex
(
".*doe"
,
"i"
);
$regex
=
new
Regex
(
'.*doe'
,
'i'
);
$results
=
DB
::
collection
(
'users'
)
->
where
(
'name'
,
'regexp'
,
$regex
)
->
get
();
$this
->
assertCount
(
2
,
$results
);
...
...
tests/QueryTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
class
QueryTest
extends
TestCase
...
...
tests/QueueTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Carbon\Carbon
;
...
...
tests/RelationsTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Collection
;
...
...
tests/SchemaTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Schema\Blueprint
;
...
...
tests/SeederTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
class
SeederTest
extends
TestCase
...
...
tests/TestCase.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Auth\Passwords\PasswordResetServiceProvider
;
...
...
tests/ValidationTest.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
class
ValidationTest
extends
TestCase
...
...
tests/config/database.php
View file @
56b874de
...
...
@@ -23,7 +23,7 @@ return [
'dsn_mongodb_db'
=>
[
'driver'
=>
'mongodb'
,
'dsn'
=>
"mongodb://
$mongoHost
:
$mongoPort
/"
.
env
(
'MONGO_DATABASE'
,
'unittest'
),
'dsn'
=>
"mongodb://
$mongoHost
:
$mongoPort
/"
.
env
(
'MONGO_DATABASE'
,
'unittest'
),
],
'mysql'
=>
[
...
...
tests/models/Address.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
...
...
tests/models/Book.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
/**
* Class Book
* Class Book
.
* @property string $title
* @property string $author
* @property array $chapters
...
...
tests/models/Client.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsToMany
;
...
...
tests/models/Group.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsToMany
;
...
...
tests/models/Item.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
...
...
@@ -6,7 +7,7 @@ use Jenssegers\Mongodb\Eloquent\Builder;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
/**
* Class Item
* Class Item
.
* @property \Carbon\Carbon $created_at
*/
class
Item
extends
Eloquent
...
...
tests/models/Location.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
...
...
tests/models/MysqlBook.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
...
...
@@ -28,7 +29,7 @@ class MysqlBook extends Eloquent
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
$schema
=
Schema
::
connection
(
'mysql'
);
if
(
!
$schema
->
hasTable
(
'books'
))
{
if
(
!
$schema
->
hasTable
(
'books'
))
{
Schema
::
connection
(
'mysql'
)
->
create
(
'books'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'title'
);
$table
->
string
(
'author_id'
)
->
nullable
();
...
...
tests/models/MysqlRole.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
...
...
@@ -32,7 +33,7 @@ class MysqlRole extends Eloquent
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
$schema
=
Schema
::
connection
(
'mysql'
);
if
(
!
$schema
->
hasTable
(
'roles'
))
{
if
(
!
$schema
->
hasTable
(
'roles'
))
{
Schema
::
connection
(
'mysql'
)
->
create
(
'roles'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'type'
);
$table
->
string
(
'user_id'
);
...
...
tests/models/MysqlUser.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\HasMany
;
...
...
@@ -38,7 +39,7 @@ class MysqlUser extends Eloquent
/** @var \Illuminate\Database\Schema\MySqlBuilder $schema */
$schema
=
Schema
::
connection
(
'mysql'
);
if
(
!
$schema
->
hasTable
(
'users'
))
{
if
(
!
$schema
->
hasTable
(
'users'
))
{
Schema
::
connection
(
'mysql'
)
->
create
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
increments
(
'id'
);
$table
->
string
(
'name'
);
...
...
tests/models/Photo.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\MorphTo
;
...
...
tests/models/Role.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
...
...
tests/models/Scoped.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Eloquent\Builder
;
...
...
tests/models/Soft.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
use
Jenssegers\Mongodb\Eloquent\SoftDeletes
;
/**
* Class Soft
* Class Soft
.
* @property \Carbon\Carbon $deleted_at
*/
class
Soft
extends
Eloquent
...
...
tests/models/User.php
View file @
56b874de
<?php
declare
(
strict_types
=
1
);
use
Illuminate\Auth\Authenticatable
;
...
...
@@ -10,7 +11,7 @@ use Jenssegers\Mongodb\Eloquent\HybridRelations;
use
Jenssegers\Mongodb\Eloquent\Model
as
Eloquent
;
/**
* Class User
* Class User
.
* @property string $_id
* @property string $name
* @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