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
140f28ea
Commit
140f28ea
authored
Oct 31, 2016
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove some overhead code
parent
959d761b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
41 deletions
+4
-41
Model.php
src/Jenssegers/Mongodb/Eloquent/Model.php
+4
-39
MorphTo.php
src/Jenssegers/Mongodb/Relations/MorphTo.php
+0
-2
No files found.
src/Jenssegers/Mongodb/Eloquent/Model.php
View file @
140f28ea
...
...
@@ -215,48 +215,13 @@ abstract class Model extends BaseModel
public
function
getAttribute
(
$key
)
{
// Check if the key is an array dot notation.
if
(
str_contains
(
$key
,
'.'
)
and
array_has
(
$this
->
attributes
,
$key
))
{
if
(
$key
and
str_contains
(
$key
,
'.'
)
and
array_has
(
$this
->
attributes
,
$key
))
{
return
$this
->
getAttributeValue
(
$key
);
}
$camelKey
=
camel_case
(
$key
);
// If the "attribute" exists as a method on the model, it may be an
// embedded model. If so, we need to return the result before it
// is handled by the parent method.
if
(
method_exists
(
$this
,
$camelKey
))
{
$method
=
new
ReflectionMethod
(
get_called_class
(),
$camelKey
);
// Ensure the method is not static to avoid conflicting with Eloquent methods.
if
(
!
$method
->
isStatic
())
{
$relations
=
$this
->
$camelKey
();
// This attribute matches an embedsOne or embedsMany relation so we need
// to return the relation results instead of the interal attributes.
if
(
$relations
instanceof
EmbedsOneOrMany
)
{
// If the key already exists in the relationships array, it just means the
// relationship has already been loaded, so we'll just return it out of
// here because there is no need to query within the relations twice.
if
(
array_key_exists
(
$key
,
$this
->
relations
))
{
return
$this
->
relations
[
$key
];
}
// Get the relation results.
return
$this
->
getRelationshipFromMethod
(
$key
,
$camelKey
);
}
if
(
$relations
instanceof
Relation
)
{
// If the key already exists in the relationships array, it just means the
// relationship has already been loaded, so we'll just return it out of
// here because there is no need to query within the relations twice.
if
(
array_key_exists
(
$key
,
$this
->
relations
)
&&
$this
->
relations
[
$key
]
!=
null
)
{
return
$this
->
relations
[
$key
];
}
// Get the relation results.
return
$this
->
getRelationshipFromMethod
(
$key
,
$camelKey
);
}
}
// This checks for embedded relation support.
if
(
method_exists
(
$this
,
$key
)
&&
!
method_exists
(
self
::
class
,
$key
))
{
return
$this
->
getRelationValue
(
$key
);
}
return
parent
::
getAttribute
(
$key
);
...
...
src/Jenssegers/Mongodb/Relations/MorphTo.php
View file @
140f28ea
...
...
@@ -31,8 +31,6 @@ class MorphTo extends EloquentMorphTo
$query
=
$instance
->
newQuery
();
$query
=
$this
->
useWithTrashed
(
$query
);
return
$query
->
whereIn
(
$key
,
$this
->
gatherKeysByType
(
$type
)
->
all
())
->
get
();
}
}
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