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
06e598a1
Commit
06e598a1
authored
Aug 28, 2015
by
fungku
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Docblocks in Model class and Embeds classes, and remove some unused arguments.
parent
00d3b8b0
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 @
06e598a1
<?php
namespace
Jenssegers\Mongodb
;
use
Carbon\Carbon
;
use
DateTime
;
use
MongoId
;
use
MongoDate
;
use
Carbon\Carbon
;
use
ReflectionMethod
;
use
MongoId
;
use
Illuminate\Database\Eloquent\Relations\Relation
;
use
Jenssegers\Mongodb\Eloquent\Builder
;
use
Jenssegers\Mongodb\Relations\EmbedsOneOrMany
;
use
Jenssegers\Mongodb\Relations\EmbedsMany
;
use
Jenssegers\Mongodb\Relations\EmbedsOne
;
use
Jenssegers\Mongodb\Relations\EmbedsOneOrMany
;
use
ReflectionMethod
;
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.
*
* @param mixed $value
*
* @return mixed
*/
public
function
getIdAttribute
(
$value
)
...
...
@@ -73,8 +72,10 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
* Define an embedded one-to-many relationship.
*
* @param string $related
* @param string $collection
* @return \Illuminate\Database\Eloquent\Relations\EmbedsMany
* @param string $localKey
* @param string $foreignKey
* @param string $relation
* @return EmbedsMany
*/
protected
function
embedsMany
(
$related
,
$localKey
=
null
,
$foreignKey
=
null
,
$relation
=
null
)
{
...
...
@@ -109,8 +110,10 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
* Define an embedded one-to-many relationship.
*
* @param string $related
* @param string $collection
* @return \Illuminate\Database\Eloquent\Relations\EmbedsMany
* @param string $localKey
* @param string $foreignKey
* @param string $relation
* @return \Jenssegers\Mongodb\Relations\EmbedsOne
*/
protected
function
embedsOne
(
$related
,
$localKey
=
null
,
$foreignKey
=
null
,
$relation
=
null
)
{
...
...
@@ -311,7 +314,7 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
array_set
(
$this
->
attributes
,
$key
,
$value
);
return
;
return
;
}
parent
::
setAttribute
(
$key
,
$value
);
...
...
@@ -406,6 +409,8 @@ return;
/**
* Remove one or more values from an array.
*
* @param string $column
* @param mixed $values
* @return mixed
*/
public
function
pull
(
$column
,
$values
)
...
...
@@ -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 array $values
...
...
@@ -474,7 +479,7 @@ return;
/**
* Set the parent relation.
*
* @param
Relation
$relation
* @param
\Illuminate\Database\Eloquent\Relations\Relation
$relation
*/
public
function
setParentRelation
(
Relation
$relation
)
{
...
...
@@ -484,7 +489,7 @@ return;
/**
* Get the parent relation.
*
* @return Relation
* @return
\Illuminate\Database\Eloquent\Relations\
Relation
*/
public
function
getParentRelation
()
{
...
...
src/Jenssegers/Mongodb/Relations/EmbedsMany.php
View file @
06e598a1
<?php
namespace
Jenssegers\Mongodb\Relations
;
use
MongoId
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Pagination\Paginator
;
use
Illuminate\Pagination\LengthAwarePaginator
;
use
Illuminate\Pagination\Paginator
;
use
MongoId
;
class
EmbedsMany
extends
EmbedsOneOrMany
{
/**
* Get the results of the relationship.
*
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return
\
Jenssegers\Mongodb\Eloquent\Collection
*/
public
function
getResults
()
{
...
...
@@ -23,7 +23,7 @@ class EmbedsMany extends EmbedsOneOrMany {
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Database\Eloquent\Model
*/
public
function
performInsert
(
Model
$model
,
array
$values
)
public
function
performInsert
(
Model
$model
)
{
// Generate a new key if needed.
if
(
$model
->
getKeyName
()
==
'_id'
and
!
$model
->
getKey
())
...
...
@@ -54,7 +54,7 @@ class EmbedsMany extends EmbedsOneOrMany {
* @param \Illuminate\Database\Eloquent\Model $model
* @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.
if
(
$this
->
isNested
())
...
...
@@ -270,10 +270,9 @@ class EmbedsMany extends EmbedsOneOrMany {
* Get a paginator for the "select" statement.
*
* @param int $perPage
* @param array $columns
* @return \Illuminate\Pagination\Paginator
*/
public
function
paginate
(
$perPage
=
null
,
$columns
=
array
(
'*'
)
)
public
function
paginate
(
$perPage
=
null
)
{
$page
=
Paginator
::
resolveCurrentPage
();
$perPage
=
$perPage
?:
$this
->
related
->
getPerPage
();
...
...
src/Jenssegers/Mongodb/Relations/EmbedsOne.php
View file @
06e598a1
<?php
namespace
Jenssegers\Mongodb\Relations
;
use
MongoId
;
use
Illuminate\Database\Eloquent\Model
;
use
MongoId
;
class
EmbedsOne
extends
EmbedsOneOrMany
{
...
...
@@ -21,7 +21,7 @@ class EmbedsOne extends EmbedsOneOrMany {
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Database\Eloquent\Model
*/
public
function
performInsert
(
Model
$model
,
array
$values
)
public
function
performInsert
(
Model
$model
)
{
// Generate a new key if needed.
if
(
$model
->
getKeyName
()
==
'_id'
and
!
$model
->
getKey
())
...
...
@@ -49,9 +49,9 @@ class EmbedsOne extends EmbedsOneOrMany {
* Save an existing model and attach it to the parent 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
())
{
...
...
@@ -74,7 +74,7 @@ class EmbedsOne extends EmbedsOneOrMany {
/**
* Delete an existing model and detach it from the parent model.
*
* @param Model $model
* @param
\Illuminate\Database\Eloquent\
Model $model
* @return int
*/
public
function
performDelete
(
Model
$model
)
...
...
src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php
View file @
06e598a1
<?php
namespace
Jenssegers\Mongodb\Relations
;
use
MongoId
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Relation
;
use
Illuminate\Database\Eloquent\Collection
as
BaseCollection
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Relations\Relation
;
use
Jenssegers\Mongodb\Eloquent\Collection
;
abstract
class
EmbedsOneOrMany
extends
Relation
{
...
...
@@ -35,10 +34,10 @@ abstract class EmbedsOneOrMany extends Relation {
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Model $related
* @param string $localKey
* @param string $foreignKey
* @param string $relation
* @return void
*/
public
function
__construct
(
Builder
$query
,
Model
$parent
,
Model
$related
,
$localKey
,
$foreignKey
,
$relation
)
{
...
...
@@ -126,7 +125,7 @@ abstract class EmbedsOneOrMany extends Relation {
/**
* Shorthand to get the results of the relationship.
*
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return
\
Jenssegers\Mongodb\Eloquent\Collection
*/
public
function
get
()
{
...
...
@@ -278,7 +277,7 @@ abstract class EmbedsOneOrMany extends Relation {
* Convert an array of records to a Collection.
*
* @param array $records
* @return Jenssegers\Mongodb\Eloquent\Collection
* @return
\
Jenssegers\Mongodb\Eloquent\Collection
*/
protected
function
toCollection
(
array
$records
=
array
())
{
...
...
@@ -322,7 +321,7 @@ abstract class EmbedsOneOrMany extends Relation {
/**
* Get the relation instance of the parent.
*
* @return Illuminate\Database\Eloquent\Relations\Relation
* @return
\
Illuminate\Database\Eloquent\Relations\Relation
*/
protected
function
getParentRelation
()
{
...
...
@@ -366,6 +365,7 @@ abstract class EmbedsOneOrMany extends Relation {
/**
* Get the fully qualified local key name.
*
* @param string $glue
* @return string
*/
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