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
ea5ec06d
Commit
ea5ec06d
authored
Aug 28, 2015
by
Jens Segers
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #568 from fungku/master
Fix Docblocks in Model class and Embed Relationship classes
parents
00d3b8b0
06e598a1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
39 deletions
+43
-39
Model.php
src/Jenssegers/Mongodb/Model.php
+20
-15
EmbedsMany.php
src/Jenssegers/Mongodb/Relations/EmbedsMany.php
+9
-10
EmbedsOne.php
src/Jenssegers/Mongodb/Relations/EmbedsOne.php
+5
-5
EmbedsOneOrMany.php
src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php
+9
-9
No files found.
src/Jenssegers/Mongodb/Model.php
View file @
ea5ec06d
<?php
namespace
Jenssegers\Mongodb
;
<?php
namespace
Jenssegers\Mongodb
;
use
Carbon\Carbon
;
use
DateTime
;
use
DateTime
;
use
MongoId
;
use
MongoDate
;
use
MongoDate
;
use
Carbon\Carbon
;
use
MongoId
;
use
ReflectionMethod
;
use
Illuminate\Database\Eloquent\Relations\Relation
;
use
Illuminate\Database\Eloquent\Relations\Relation
;
use
Jenssegers\Mongodb\Eloquent\Builder
;
use
Jenssegers\Mongodb\Eloquent\Builder
;
use
Jenssegers\Mongodb\Relations\EmbedsOneOrMany
;
use
Jenssegers\Mongodb\Relations\EmbedsMany
;
use
Jenssegers\Mongodb\Relations\EmbedsMany
;
use
Jenssegers\Mongodb\Relations\EmbedsOne
;
use
Jenssegers\Mongodb\Relations\EmbedsOne
;
use
Jenssegers\Mongodb\Relations\EmbedsOneOrMany
;
use
ReflectionMethod
;
abstract
class
Model
extends
\Jenssegers\Eloquent\Model
{
abstract
class
Model
extends
\Jenssegers\Eloquent\Model
{
...
@@ -38,7 +38,6 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
...
@@ -38,7 +38,6 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
* Custom accessor for the model's id.
* Custom accessor for the model's id.
*
*
* @param mixed $value
* @param mixed $value
*
* @return mixed
* @return mixed
*/
*/
public
function
getIdAttribute
(
$value
)
public
function
getIdAttribute
(
$value
)
...
@@ -73,8 +72,10 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
...
@@ -73,8 +72,10 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
* Define an embedded one-to-many relationship.
* Define an embedded one-to-many relationship.
*
*
* @param string $related
* @param string $related
* @param string $collection
* @param string $localKey
* @return \Illuminate\Database\Eloquent\Relations\EmbedsMany
* @param string $foreignKey
* @param string $relation
* @return EmbedsMany
*/
*/
protected
function
embedsMany
(
$related
,
$localKey
=
null
,
$foreignKey
=
null
,
$relation
=
null
)
protected
function
embedsMany
(
$related
,
$localKey
=
null
,
$foreignKey
=
null
,
$relation
=
null
)
{
{
...
@@ -109,8 +110,10 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
...
@@ -109,8 +110,10 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
* Define an embedded one-to-many relationship.
* Define an embedded one-to-many relationship.
*
*
* @param string $related
* @param string $related
* @param string $collection
* @param string $localKey
* @return \Illuminate\Database\Eloquent\Relations\EmbedsMany
* @param string $foreignKey
* @param string $relation
* @return \Jenssegers\Mongodb\Relations\EmbedsOne
*/
*/
protected
function
embedsOne
(
$related
,
$localKey
=
null
,
$foreignKey
=
null
,
$relation
=
null
)
protected
function
embedsOne
(
$related
,
$localKey
=
null
,
$foreignKey
=
null
,
$relation
=
null
)
{
{
...
@@ -311,7 +314,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
...
@@ -311,7 +314,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
array_set
(
$this
->
attributes
,
$key
,
$value
);
array_set
(
$this
->
attributes
,
$key
,
$value
);
return
;
return
;
}
}
parent
::
setAttribute
(
$key
,
$value
);
parent
::
setAttribute
(
$key
,
$value
);
...
@@ -406,6 +409,8 @@ return;
...
@@ -406,6 +409,8 @@ return;
/**
/**
* Remove one or more values from an array.
* Remove one or more values from an array.
*
*
* @param string $column
* @param mixed $values
* @return mixed
* @return mixed
*/
*/
public
function
pull
(
$column
,
$values
)
public
function
pull
(
$column
,
$values
)
...
@@ -446,7 +451,7 @@ return;
...
@@ -446,7 +451,7 @@ return;
}
}
/**
/**
* Rem
p
ove one or more values to the underlying attribute value and sync with original.
* Remove one or more values to the underlying attribute value and sync with original.
*
*
* @param string $column
* @param string $column
* @param array $values
* @param array $values
...
@@ -474,7 +479,7 @@ return;
...
@@ -474,7 +479,7 @@ return;
/**
/**
* Set the parent relation.
* Set the parent relation.
*
*
* @param
Relation
$relation
* @param
\Illuminate\Database\Eloquent\Relations\Relation
$relation
*/
*/
public
function
setParentRelation
(
Relation
$relation
)
public
function
setParentRelation
(
Relation
$relation
)
{
{
...
@@ -484,7 +489,7 @@ return;
...
@@ -484,7 +489,7 @@ return;
/**
/**
* Get the parent relation.
* Get the parent relation.
*
*
* @return Relation
* @return
\Illuminate\Database\Eloquent\Relations\
Relation
*/
*/
public
function
getParentRelation
()
public
function
getParentRelation
()
{
{
...
...
src/Jenssegers/Mongodb/Relations/EmbedsMany.php
View file @
ea5ec06d
<?php
namespace
Jenssegers\Mongodb\Relations
;
<?php
namespace
Jenssegers\Mongodb\Relations
;
use
MongoId
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Pagination\Paginator
;
use
Illuminate\Pagination\LengthAwarePaginator
;
use
Illuminate\Pagination\LengthAwarePaginator
;
use
Illuminate\Pagination\Paginator
;
use
MongoId
;
class
EmbedsMany
extends
EmbedsOneOrMany
{
class
EmbedsMany
extends
EmbedsOneOrMany
{
/**
/**
* Get the results of the relationship.
* Get the results of the relationship.
*
*
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return
\
Jenssegers\Mongodb\Eloquent\Collection
*/
*/
public
function
getResults
()
public
function
getResults
()
{
{
...
@@ -23,7 +23,7 @@ class EmbedsMany extends EmbedsOneOrMany {
...
@@ -23,7 +23,7 @@ class EmbedsMany extends EmbedsOneOrMany {
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Database\Eloquent\Model
* @return \Illuminate\Database\Eloquent\Model
*/
*/
public
function
performInsert
(
Model
$model
,
array
$values
)
public
function
performInsert
(
Model
$model
)
{
{
// Generate a new key if needed.
// Generate a new key if needed.
if
(
$model
->
getKeyName
()
==
'_id'
and
!
$model
->
getKey
())
if
(
$model
->
getKeyName
()
==
'_id'
and
!
$model
->
getKey
())
...
@@ -54,7 +54,7 @@ class EmbedsMany extends EmbedsOneOrMany {
...
@@ -54,7 +54,7 @@ class EmbedsMany extends EmbedsOneOrMany {
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
* @return Model|bool
* @return Model|bool
*/
*/
public
function
performUpdate
(
Model
$model
,
array
$values
)
public
function
performUpdate
(
Model
$model
)
{
{
// For deeply nested documents, let the parent handle the changes.
// For deeply nested documents, let the parent handle the changes.
if
(
$this
->
isNested
())
if
(
$this
->
isNested
())
...
@@ -270,10 +270,9 @@ class EmbedsMany extends EmbedsOneOrMany {
...
@@ -270,10 +270,9 @@ class EmbedsMany extends EmbedsOneOrMany {
* Get a paginator for the "select" statement.
* Get a paginator for the "select" statement.
*
*
* @param int $perPage
* @param int $perPage
* @param array $columns
* @return \Illuminate\Pagination\Paginator
* @return \Illuminate\Pagination\Paginator
*/
*/
public
function
paginate
(
$perPage
=
null
,
$columns
=
array
(
'*'
)
)
public
function
paginate
(
$perPage
=
null
)
{
{
$page
=
Paginator
::
resolveCurrentPage
();
$page
=
Paginator
::
resolveCurrentPage
();
$perPage
=
$perPage
?:
$this
->
related
->
getPerPage
();
$perPage
=
$perPage
?:
$this
->
related
->
getPerPage
();
...
...
src/Jenssegers/Mongodb/Relations/EmbedsOne.php
View file @
ea5ec06d
<?php
namespace
Jenssegers\Mongodb\Relations
;
<?php
namespace
Jenssegers\Mongodb\Relations
;
use
MongoId
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
MongoId
;
class
EmbedsOne
extends
EmbedsOneOrMany
{
class
EmbedsOne
extends
EmbedsOneOrMany
{
...
@@ -21,7 +21,7 @@ class EmbedsOne extends EmbedsOneOrMany {
...
@@ -21,7 +21,7 @@ class EmbedsOne extends EmbedsOneOrMany {
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Database\Eloquent\Model
* @return \Illuminate\Database\Eloquent\Model
*/
*/
public
function
performInsert
(
Model
$model
,
array
$values
)
public
function
performInsert
(
Model
$model
)
{
{
// Generate a new key if needed.
// Generate a new key if needed.
if
(
$model
->
getKeyName
()
==
'_id'
and
!
$model
->
getKey
())
if
(
$model
->
getKeyName
()
==
'_id'
and
!
$model
->
getKey
())
...
@@ -49,9 +49,9 @@ class EmbedsOne extends EmbedsOneOrMany {
...
@@ -49,9 +49,9 @@ class EmbedsOne extends EmbedsOneOrMany {
* Save an existing model and attach it to the parent model.
* Save an existing model and attach it to the parent model.
*
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
* @return Model|bool
* @return
\Illuminate\Database\Eloquent\
Model|bool
*/
*/
public
function
performUpdate
(
Model
$model
,
array
$values
)
public
function
performUpdate
(
Model
$model
)
{
{
if
(
$this
->
isNested
())
if
(
$this
->
isNested
())
{
{
...
@@ -74,7 +74,7 @@ class EmbedsOne extends EmbedsOneOrMany {
...
@@ -74,7 +74,7 @@ class EmbedsOne extends EmbedsOneOrMany {
/**
/**
* Delete an existing model and detach it from the parent model.
* Delete an existing model and detach it from the parent model.
*
*
* @param Model $model
* @param
\Illuminate\Database\Eloquent\
Model $model
* @return int
* @return int
*/
*/
public
function
performDelete
(
Model
$model
)
public
function
performDelete
(
Model
$model
)
...
...
src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php
View file @
ea5ec06d
<?php
namespace
Jenssegers\Mongodb\Relations
;
<?php
namespace
Jenssegers\Mongodb\Relations
;
use
MongoId
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Relation
;
use
Illuminate\Database\Eloquent\Collection
as
BaseCollection
;
use
Illuminate\Database\Eloquent\Collection
as
BaseCollection
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Relations\Relation
;
use
Jenssegers\Mongodb\Eloquent\Collection
;
use
Jenssegers\Mongodb\Eloquent\Collection
;
abstract
class
EmbedsOneOrMany
extends
Relation
{
abstract
class
EmbedsOneOrMany
extends
Relation
{
...
@@ -35,10 +34,10 @@ abstract class EmbedsOneOrMany extends Relation {
...
@@ -35,10 +34,10 @@ abstract class EmbedsOneOrMany extends Relation {
*
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Model $related
* @param string $localKey
* @param string $localKey
* @param string $foreignKey
* @param string $foreignKey
* @param string $relation
* @param string $relation
* @return void
*/
*/
public
function
__construct
(
Builder
$query
,
Model
$parent
,
Model
$related
,
$localKey
,
$foreignKey
,
$relation
)
public
function
__construct
(
Builder
$query
,
Model
$parent
,
Model
$related
,
$localKey
,
$foreignKey
,
$relation
)
{
{
...
@@ -126,7 +125,7 @@ abstract class EmbedsOneOrMany extends Relation {
...
@@ -126,7 +125,7 @@ abstract class EmbedsOneOrMany extends Relation {
/**
/**
* Shorthand to get the results of the relationship.
* Shorthand to get the results of the relationship.
*
*
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return
\
Jenssegers\Mongodb\Eloquent\Collection
*/
*/
public
function
get
()
public
function
get
()
{
{
...
@@ -278,7 +277,7 @@ abstract class EmbedsOneOrMany extends Relation {
...
@@ -278,7 +277,7 @@ abstract class EmbedsOneOrMany extends Relation {
* Convert an array of records to a Collection.
* Convert an array of records to a Collection.
*
*
* @param array $records
* @param array $records
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return
\
Jenssegers\Mongodb\Eloquent\Collection
*/
*/
protected
function
toCollection
(
array
$records
=
array
())
protected
function
toCollection
(
array
$records
=
array
())
{
{
...
@@ -322,7 +321,7 @@ abstract class EmbedsOneOrMany extends Relation {
...
@@ -322,7 +321,7 @@ abstract class EmbedsOneOrMany extends Relation {
/**
/**
* Get the relation instance of the parent.
* Get the relation instance of the parent.
*
*
* @return Illuminate\Database\Eloquent\Relations\Relation
* @return
\
Illuminate\Database\Eloquent\Relations\Relation
*/
*/
protected
function
getParentRelation
()
protected
function
getParentRelation
()
{
{
...
@@ -366,6 +365,7 @@ abstract class EmbedsOneOrMany extends Relation {
...
@@ -366,6 +365,7 @@ abstract class EmbedsOneOrMany extends Relation {
/**
/**
* Get the fully qualified local key name.
* Get the fully qualified local key name.
*
*
* @param string $glue
* @return string
* @return string
*/
*/
protected
function
getPathHierarchy
(
$glue
=
'.'
)
protected
function
getPathHierarchy
(
$glue
=
'.'
)
...
...
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