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
cb59979a
Commit
cb59979a
authored
Aug 06, 2014
by
Kévin Bargoin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor _id attribute getter
parent
1722daf4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
15 deletions
+7
-15
Model.php
src/Jenssegers/Mongodb/Model.php
+7
-15
No files found.
src/Jenssegers/Mongodb/Model.php
View file @
cb59979a
...
...
@@ -49,7 +49,10 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
*/
public
function
getIdAttribute
(
$value
)
{
if
(
$value
)
{
if
(
!
$value
&&
array_key_exists
(
'_id'
,
$this
->
attributes
))
{
$value
=
$this
->
attributes
[
'_id'
];
}
// Return _id as string
if
(
$value
instanceof
MongoId
)
{
return
(
string
)
$value
;
...
...
@@ -58,17 +61,6 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
return
$value
;
}
if
(
array_key_exists
(
'_id'
,
$this
->
attributes
))
{
// Return _id as string
if
(
$this
->
attributes
[
'_id'
]
instanceof
MongoId
)
{
return
(
string
)
$this
->
attributes
[
'_id'
];
}
return
$this
->
attributes
[
'_id'
];
}
}
/**
* Define an embedded one-to-many relationship.
*
...
...
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