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
ab5b3844
Commit
ab5b3844
authored
Aug 25, 2016
by
pi0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformat and FIX
parent
b0e2a184
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
22 deletions
+26
-22
Builder.php
src/Jenssegers/Mongodb/Eloquent/Builder.php
+26
-22
No files found.
src/Jenssegers/Mongodb/Eloquent/Builder.php
View file @
ab5b3844
...
@@ -20,8 +20,8 @@ class Builder extends EloquentBuilder
...
@@ -20,8 +20,8 @@ class Builder extends EloquentBuilder
/**
/**
* Update a record in the database.
* Update a record in the database.
*
*
* @param array $values
* @param array
$values
* @param array $options
* @param array
$options
* @return int
* @return int
*/
*/
public
function
update
(
array
$values
,
array
$options
=
[])
public
function
update
(
array
$values
,
array
$options
=
[])
...
@@ -40,7 +40,7 @@ class Builder extends EloquentBuilder
...
@@ -40,7 +40,7 @@ class Builder extends EloquentBuilder
/**
/**
* Insert a new record into the database.
* Insert a new record into the database.
*
*
* @param array $values
* @param array
$values
* @return bool
* @return bool
*/
*/
public
function
insert
(
array
$values
)
public
function
insert
(
array
$values
)
...
@@ -59,8 +59,8 @@ class Builder extends EloquentBuilder
...
@@ -59,8 +59,8 @@ class Builder extends EloquentBuilder
/**
/**
* Insert a new record and get the value of the primary key.
* Insert a new record and get the value of the primary key.
*
*
* @param array $values
* @param array
$values
* @param string $sequence
* @param string
$sequence
* @return int
* @return int
*/
*/
public
function
insertGetId
(
array
$values
,
$sequence
=
null
)
public
function
insertGetId
(
array
$values
,
$sequence
=
null
)
...
@@ -97,9 +97,9 @@ class Builder extends EloquentBuilder
...
@@ -97,9 +97,9 @@ class Builder extends EloquentBuilder
/**
/**
* Increment a column's value by a given amount.
* Increment a column's value by a given amount.
*
*
* @param string $column
* @param string
$column
* @param int $amount
* @param int
$amount
* @param array $extra
* @param array
$extra
* @return int
* @return int
*/
*/
public
function
increment
(
$column
,
$amount
=
1
,
array
$extra
=
[])
public
function
increment
(
$column
,
$amount
=
1
,
array
$extra
=
[])
...
@@ -127,9 +127,9 @@ class Builder extends EloquentBuilder
...
@@ -127,9 +127,9 @@ class Builder extends EloquentBuilder
/**
/**
* Decrement a column's value by a given amount.
* Decrement a column's value by a given amount.
*
*
* @param string $column
* @param string
$column
* @param int $amount
* @param int
$amount
* @param array $extra
* @param array
$extra
* @return int
* @return int
*/
*/
public
function
decrement
(
$column
,
$amount
=
1
,
array
$extra
=
[])
public
function
decrement
(
$column
,
$amount
=
1
,
array
$extra
=
[])
...
@@ -155,11 +155,11 @@ class Builder extends EloquentBuilder
...
@@ -155,11 +155,11 @@ class Builder extends EloquentBuilder
/**
/**
* Add the "has" condition where clause to the query.
* Add the "has" condition where clause to the query.
*
*
* @param \Illuminate\Database\Eloquent\Builder $hasQuery
* @param \Illuminate\Database\Eloquent\Builder
$hasQuery
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
* @param \Illuminate\Database\Eloquent\Relations\Relation
$relation
* @param string $operator
* @param string
$operator
* @param int $count
* @param int
$count
* @param string $boolean
* @param string
$boolean
* @return \Illuminate\Database\Eloquent\Builder
* @return \Illuminate\Database\Eloquent\Builder
*/
*/
protected
function
addHasWhere
(
EloquentBuilder
$hasQuery
,
Relation
$relation
,
$operator
,
$count
,
$boolean
)
protected
function
addHasWhere
(
EloquentBuilder
$hasQuery
,
Relation
$relation
,
$operator
,
$count
,
$boolean
)
...
@@ -168,7 +168,7 @@ class Builder extends EloquentBuilder
...
@@ -168,7 +168,7 @@ class Builder extends EloquentBuilder
// Get the number of related objects for each possible parent.
// Get the number of related objects for each possible parent.
$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
},
$query
->
pluck
(
$relation
->
getHasCompareKey
())));
},
$query
->
pluck
(
$relation
->
getHasCompareKey
())));
// Remove unwanted related objects based on the operator and count.
// Remove unwanted related objects based on the operator and count.
...
@@ -209,7 +209,7 @@ class Builder extends EloquentBuilder
...
@@ -209,7 +209,7 @@ class Builder extends EloquentBuilder
/**
/**
* Create a raw database expression.
* Create a raw database expression.
*
*
* @param closure $expression
* @param closure
$expression
* @return mixed
* @return mixed
*/
*/
public
function
raw
(
$expression
=
null
)
public
function
raw
(
$expression
=
null
)
...
@@ -221,13 +221,17 @@ class Builder extends EloquentBuilder
...
@@ -221,13 +221,17 @@ class Builder extends EloquentBuilder
if
(
$results
instanceof
Cursor
)
{
if
(
$results
instanceof
Cursor
)
{
$results
=
iterator_to_array
(
$results
,
false
);
$results
=
iterator_to_array
(
$results
,
false
);
return
$this
->
model
->
hydrate
(
$results
);
return
$this
->
model
->
hydrate
(
$results
);
}
// Convert Mongo BSONDocument to a single object.
}
// Convert Mongo BSONDocument to a single object.
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
;
...
...
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