8000 [12.x] Ensure related models is iterable on `HasRelationships@relationLoaded()` by rodrigopedra · Pull Request #55519 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[12.x] Ensure related models is iterable on HasRelationships@relationLoaded() #55519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ensure related models is iterable
  • Loading branch information
rodrigopedra committed Apr 22, 2025
commit 76175021180bcd4316aac0a16865c016b6447ed7
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,11 @@ public function relationLoaded($key)
}

if ($nestedRelation !== null) {
foreach ($this->$relation as $related) {
$relatedModels = is_iterable($relatedModels = $this->$relation)
? $relatedModels
: [$relatedModels];

foreach ($relatedModels as $related) {
if (! $related->relationLoaded($nestedRelation)) {
return false;
}
Expand Down
0