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
577678e1
Commit
577678e1
authored
Sep 05, 2017
by
Jens Segers
Committed by
StyleCI Bot
Sep 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply fixes from StyleCI
parent
e4816615
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
24 deletions
+24
-24
Collection.php
src/Jenssegers/Mongodb/Collection.php
+1
-1
Builder.php
src/Jenssegers/Mongodb/Eloquent/Builder.php
+2
-2
Model.php
src/Jenssegers/Mongodb/Eloquent/Model.php
+3
-3
QueriesRelationships.php
src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php
+1
-1
Builder.php
src/Jenssegers/Mongodb/Query/Builder.php
+7
-7
MongoFailedJobProvider.php
...enssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php
+2
-2
BelongsToMany.php
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
+6
-6
EmbedsOneOrMany.php
src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php
+2
-2
No files found.
src/Jenssegers/Mongodb/Collection.php
View file @
577678e1
...
@@ -55,7 +55,7 @@ class Collection
...
@@ -55,7 +55,7 @@ class Collection
// Convert the query parameters to a json string.
// Convert the query parameters to a json string.
array_walk_recursive
(
$parameters
,
function
(
&
$item
,
$key
)
{
array_walk_recursive
(
$parameters
,
function
(
&
$item
,
$key
)
{
if
(
$item
instanceof
ObjectID
)
{
if
(
$item
instanceof
ObjectID
)
{
$item
=
(
string
)
$item
;
$item
=
(
string
)
$item
;
}
}
});
});
...
...
src/Jenssegers/Mongodb/Eloquent/Builder.php
View file @
577678e1
...
@@ -160,10 +160,10 @@ class Builder extends EloquentBuilder
...
@@ -160,10 +160,10 @@ class Builder extends EloquentBuilder
elseif
(
$results
instanceof
BSONDocument
)
{
elseif
(
$results
instanceof
BSONDocument
)
{
$results
=
$results
->
getArrayCopy
();
$results
=
$results
->
getArrayCopy
();
return
$this
->
model
->
newFromBuilder
((
array
)
$results
);
return
$this
->
model
->
newFromBuilder
((
array
)
$results
);
}
// The result is a single object.
}
// The result is a single object.
elseif
(
is_array
(
$results
)
and
array_key_exists
(
'_id'
,
$results
))
{
elseif
(
is_array
(
$results
)
and
array_key_exists
(
'_id'
,
$results
))
{
return
$this
->
model
->
newFromBuilder
((
array
)
$results
);
return
$this
->
model
->
newFromBuilder
((
array
)
$results
);
}
}
return
$results
;
return
$results
;
...
...
src/Jenssegers/Mongodb/Eloquent/Model.php
View file @
577678e1
...
@@ -52,7 +52,7 @@ abstract class Model extends BaseModel
...
@@ -52,7 +52,7 @@ abstract class Model extends BaseModel
// Convert ObjectID to string.
// Convert ObjectID to string.
if
(
$value
instanceof
ObjectID
)
{
if
(
$value
instanceof
ObjectID
)
{
return
(
string
)
$value
;
return
(
string
)
$value
;
}
}
return
$value
;
return
$value
;
...
@@ -193,14 +193,14 @@ abstract class Model extends BaseModel
...
@@ -193,14 +193,14 @@ abstract class Model extends BaseModel
// nicely when your models are converted to JSON.
// nicely when your models are converted to JSON.
foreach
(
$attributes
as
$key
=>
&
$value
)
{
foreach
(
$attributes
as
$key
=>
&
$value
)
{
if
(
$value
instanceof
ObjectID
)
{
if
(
$value
instanceof
ObjectID
)
{
$value
=
(
string
)
$value
;
$value
=
(
string
)
$value
;
}
}
}
}
// Convert dot-notation dates.
// Convert dot-notation dates.
foreach
(
$this
->
getDates
()
as
$key
)
{
foreach
(
$this
->
getDates
()
as
$key
)
{
if
(
str_contains
(
$key
,
'.'
)
and
array_has
(
$attributes
,
$key
))
{
if
(
str_contains
(
$key
,
'.'
)
and
array_has
(
$attributes
,
$key
))
{
array_set
(
$attributes
,
$key
,
(
string
)
$this
->
asDateTime
(
array_get
(
$attributes
,
$key
)));
array_set
(
$attributes
,
$key
,
(
string
)
$this
->
asDateTime
(
array_get
(
$attributes
,
$key
)));
}
}
}
}
...
...
src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php
View file @
577678e1
...
@@ -137,7 +137,7 @@ trait QueriesRelationships
...
@@ -137,7 +137,7 @@ trait QueriesRelationships
protected
function
getConstrainedRelatedIds
(
$relations
,
$operator
,
$count
)
protected
function
getConstrainedRelatedIds
(
$relations
,
$operator
,
$count
)
{
{
$relationCount
=
array_count_values
(
array_map
(
function
(
$id
)
{
$relationCount
=
array_count_values
(
array_map
(
function
(
$id
)
{
return
(
string
)
$id
;
// Convert Back ObjectIds to Strings
return
(
string
)
$id
;
// Convert Back ObjectIds to Strings
},
is_array
(
$relations
)
?
$relations
:
$relations
->
flatten
()
->
toArray
()));
},
is_array
(
$relations
)
?
$relations
:
$relations
->
flatten
()
->
toArray
()));
// Remove unwanted related objects based on the operator and count.
// Remove unwanted related objects based on the operator and count.
$relationCount
=
array_filter
(
$relationCount
,
function
(
$counted
)
use
(
$count
,
$operator
)
{
$relationCount
=
array_filter
(
$relationCount
,
function
(
$counted
)
use
(
$count
,
$operator
)
{
...
...
src/Jenssegers/Mongodb/Query/Builder.php
View file @
577678e1
...
@@ -444,7 +444,7 @@ class Builder extends BaseBuilder
...
@@ -444,7 +444,7 @@ class Builder extends BaseBuilder
$this
->
bindings
[
'select'
]
=
$previousSelectBindings
;
$this
->
bindings
[
'select'
]
=
$previousSelectBindings
;
if
(
isset
(
$results
[
0
]))
{
if
(
isset
(
$results
[
0
]))
{
$result
=
(
array
)
$results
[
0
];
$result
=
(
array
)
$results
[
0
];
return
$result
[
'aggregate'
];
return
$result
[
'aggregate'
];
}
}
...
@@ -537,7 +537,7 @@ class Builder extends BaseBuilder
...
@@ -537,7 +537,7 @@ class Builder extends BaseBuilder
// Batch insert
// Batch insert
$result
=
$this
->
collection
->
insertMany
(
$values
);
$result
=
$this
->
collection
->
insertMany
(
$values
);
return
(
1
==
(
int
)
$result
->
isAcknowledged
());
return
(
1
==
(
int
)
$result
->
isAcknowledged
());
}
}
/**
/**
...
@@ -547,7 +547,7 @@ class Builder extends BaseBuilder
...
@@ -547,7 +547,7 @@ class Builder extends BaseBuilder
{
{
$result
=
$this
->
collection
->
insertOne
(
$values
);
$result
=
$this
->
collection
->
insertOne
(
$values
);
if
(
1
==
(
int
)
$result
->
isAcknowledged
())
{
if
(
1
==
(
int
)
$result
->
isAcknowledged
())
{
if
(
is_null
(
$sequence
))
{
if
(
is_null
(
$sequence
))
{
$sequence
=
'_id'
;
$sequence
=
'_id'
;
}
}
...
@@ -609,7 +609,7 @@ class Builder extends BaseBuilder
...
@@ -609,7 +609,7 @@ class Builder extends BaseBuilder
// Convert ObjectID's to strings
// Convert ObjectID's to strings
if
(
$key
==
'_id'
)
{
if
(
$key
==
'_id'
)
{
$results
=
$results
->
map
(
function
(
$item
)
{
$results
=
$results
->
map
(
function
(
$item
)
{
$item
[
'_id'
]
=
(
string
)
$item
[
'_id'
];
$item
[
'_id'
]
=
(
string
)
$item
[
'_id'
];
return
$item
;
return
$item
;
});
});
}
}
...
@@ -632,7 +632,7 @@ class Builder extends BaseBuilder
...
@@ -632,7 +632,7 @@ class Builder extends BaseBuilder
$wheres
=
$this
->
compileWheres
();
$wheres
=
$this
->
compileWheres
();
$result
=
$this
->
collection
->
DeleteMany
(
$wheres
);
$result
=
$this
->
collection
->
DeleteMany
(
$wheres
);
if
(
1
==
(
int
)
$result
->
isAcknowledged
())
{
if
(
1
==
(
int
)
$result
->
isAcknowledged
())
{
return
$result
->
getDeletedCount
();
return
$result
->
getDeletedCount
();
}
}
...
@@ -658,7 +658,7 @@ class Builder extends BaseBuilder
...
@@ -658,7 +658,7 @@ class Builder extends BaseBuilder
{
{
$result
=
$this
->
collection
->
drop
();
$result
=
$this
->
collection
->
drop
();
return
(
1
==
(
int
)
$result
->
ok
);
return
(
1
==
(
int
)
$result
->
ok
);
}
}
/**
/**
...
@@ -789,7 +789,7 @@ class Builder extends BaseBuilder
...
@@ -789,7 +789,7 @@ class Builder extends BaseBuilder
$wheres
=
$this
->
compileWheres
();
$wheres
=
$this
->
compileWheres
();
$result
=
$this
->
collection
->
UpdateMany
(
$wheres
,
$query
,
$options
);
$result
=
$this
->
collection
->
UpdateMany
(
$wheres
,
$query
,
$options
);
if
(
1
==
(
int
)
$result
->
isAcknowledged
())
{
if
(
1
==
(
int
)
$result
->
isAcknowledged
())
{
return
$result
->
getModifiedCount
()
?
$result
->
getModifiedCount
()
:
$result
->
getUpsertedCount
();
return
$result
->
getModifiedCount
()
?
$result
->
getModifiedCount
()
:
$result
->
getUpsertedCount
();
}
}
...
...
src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php
View file @
577678e1
...
@@ -33,7 +33,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
...
@@ -33,7 +33,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
$all
=
$this
->
getTable
()
->
orderBy
(
'_id'
,
'desc'
)
->
get
()
->
all
();
$all
=
$this
->
getTable
()
->
orderBy
(
'_id'
,
'desc'
)
->
get
()
->
all
();
$all
=
array_map
(
function
(
$job
)
{
$all
=
array_map
(
function
(
$job
)
{
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
return
$job
;
return
$job
;
},
$all
);
},
$all
);
...
@@ -50,7 +50,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
...
@@ -50,7 +50,7 @@ class MongoFailedJobProvider extends DatabaseFailedJobProvider
{
{
$job
=
$this
->
getTable
()
->
find
(
$id
);
$job
=
$this
->
getTable
()
->
find
(
$id
);
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
return
$job
;
return
$job
;
}
}
...
...
src/Jenssegers/Mongodb/Relations/BelongsToMany.php
View file @
577678e1
...
@@ -146,8 +146,8 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -146,8 +146,8 @@ class BelongsToMany extends EloquentBelongsToMany
if
(
$detaching
and
count
(
$detach
)
>
0
)
{
if
(
$detaching
and
count
(
$detach
)
>
0
)
{
$this
->
detach
(
$detach
);
$this
->
detach
(
$detach
);
$changes
[
'detached'
]
=
(
array
)
array_map
(
function
(
$v
)
{
$changes
[
'detached'
]
=
(
array
)
array_map
(
function
(
$v
)
{
return
is_numeric
(
$v
)
?
(
int
)
$v
:
(
string
)
$v
;
return
is_numeric
(
$v
)
?
(
int
)
$v
:
(
string
)
$v
;
},
$detach
);
},
$detach
);
}
}
...
@@ -192,14 +192,14 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -192,14 +192,14 @@ class BelongsToMany extends EloquentBelongsToMany
$query
=
$this
->
newRelatedQuery
();
$query
=
$this
->
newRelatedQuery
();
$query
->
whereIn
(
$this
->
related
->
getKeyName
(),
(
array
)
$id
);
$query
->
whereIn
(
$this
->
related
->
getKeyName
(),
(
array
)
$id
);
// Attach the new parent id to the related model.
// Attach the new parent id to the related model.
$query
->
push
(
$this
->
foreignKey
,
$this
->
parent
->
getKey
(),
true
);
$query
->
push
(
$this
->
foreignKey
,
$this
->
parent
->
getKey
(),
true
);
}
}
// Attach the new ids to the parent model.
// Attach the new ids to the parent model.
$this
->
parent
->
push
(
$this
->
getRelatedKey
(),
(
array
)
$id
,
true
);
$this
->
parent
->
push
(
$this
->
getRelatedKey
(),
(
array
)
$id
,
true
);
if
(
$touch
)
{
if
(
$touch
)
{
$this
->
touchIfTouching
();
$this
->
touchIfTouching
();
...
@@ -212,7 +212,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -212,7 +212,7 @@ class BelongsToMany extends EloquentBelongsToMany
public
function
detach
(
$ids
=
[],
$touch
=
true
)
public
function
detach
(
$ids
=
[],
$touch
=
true
)
{
{
if
(
$ids
instanceof
Model
)
{
if
(
$ids
instanceof
Model
)
{
$ids
=
(
array
)
$ids
->
getKey
();
$ids
=
(
array
)
$ids
->
getKey
();
}
}
$query
=
$this
->
newRelatedQuery
();
$query
=
$this
->
newRelatedQuery
();
...
@@ -220,7 +220,7 @@ class BelongsToMany extends EloquentBelongsToMany
...
@@ -220,7 +220,7 @@ class BelongsToMany extends EloquentBelongsToMany
// If associated IDs were passed to the method we will only delete those
// If associated IDs were passed to the method we will only delete those
// associations, otherwise all of the association ties will be broken.
// associations, otherwise all of the association ties will be broken.
// We'll return the numbers of affected rows when we do the deletes.
// We'll return the numbers of affected rows when we do the deletes.
$ids
=
(
array
)
$ids
;
$ids
=
(
array
)
$ids
;
// Detach all ids from the parent model.
// Detach all ids from the parent model.
$this
->
parent
->
pull
(
$this
->
getRelatedKey
(),
$ids
);
$this
->
parent
->
pull
(
$this
->
getRelatedKey
(),
$ids
);
...
...
src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php
View file @
577678e1
...
@@ -210,7 +210,7 @@ abstract class EmbedsOneOrMany extends Relation
...
@@ -210,7 +210,7 @@ abstract class EmbedsOneOrMany extends Relation
$attributes
=
$this
->
parent
->
getAttributes
();
$attributes
=
$this
->
parent
->
getAttributes
();
// Get embedded models form parent attributes.
// Get embedded models form parent attributes.
$embedded
=
isset
(
$attributes
[
$this
->
localKey
])
?
(
array
)
$attributes
[
$this
->
localKey
]
:
null
;
$embedded
=
isset
(
$attributes
[
$this
->
localKey
])
?
(
array
)
$attributes
[
$this
->
localKey
]
:
null
;
return
$embedded
;
return
$embedded
;
}
}
...
@@ -280,7 +280,7 @@ abstract class EmbedsOneOrMany extends Relation
...
@@ -280,7 +280,7 @@ abstract class EmbedsOneOrMany extends Relation
return
;
return
;
}
}
$model
=
$this
->
related
->
newFromBuilder
((
array
)
$attributes
);
$model
=
$this
->
related
->
newFromBuilder
((
array
)
$attributes
);
$model
->
setParentRelation
(
$this
);
$model
->
setParentRelation
(
$this
);
...
...
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