Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
71f8e4ac
Commit
71f8e4ac
authored
Jul 12, 2012
by
Franz Liedke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug introduced in pull request #799 that caused eager loading constraints to stop working.
parent
1503aed7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
11 deletions
+24
-11
model.php
laravel/database/eloquent/model.php
+24
-11
No files found.
laravel/database/eloquent/model.php
View file @
71f8e4ac
...
...
@@ -257,25 +257,38 @@ abstract class Model {
{
$includes
=
(
array
)
$includes
;
$
all
_includes
=
array
();
$
given
_includes
=
array
();
foreach
(
$includes
as
$include
)
foreach
(
$includes
as
$relationship
=>
$constraints
)
{
$nested
=
explode
(
'.'
,
$include
);
// When eager loading relationships, constraints may be set on the eager
// load definition; however, is none are set, we need to swap the key
// and the value of the array since there are no constraints.
if
(
is_numeric
(
$relationship
))
{
list
(
$relationship
,
$constraints
)
=
array
(
$constraints
,
null
);
}
$given_includes
[
$relationship
]
=
$constraints
;
}
$inc
=
array
();
$relationships
=
array_keys
(
$given_includes
);
$implicits
=
array
();
foreach
(
$nested
as
$relation
)
foreach
(
$relationships
as
$relationship
)
{
$inc
[]
=
$relation
;
$parts
=
explode
(
'.'
,
$relationship
)
;
$all_includes
[]
=
implode
(
'.'
,
$inc
);
$prefix
=
''
;
foreach
(
$parts
as
$part
)
{
$implicits
[
$prefix
.
$part
]
=
null
;
$prefix
.=
$part
.
'.'
;
}
}
//
remove duplicates and reset the array keys.
$this
->
includes
=
array_values
(
array_unique
(
$all_includes
))
;
//
Add all implicit includes to the explicit ones
$this
->
includes
=
$given_includes
+
$implicits
;
return
$this
;
}
...
...
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