8000 [12.x] Adds `EagerLoad` attribute and `initializeOnQueue` hook by timacdonald · Pull Request #55590 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[12.x] Adds EagerLoad attribute and initializeOnQueue hook #55590

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

Draft
wants to merge 19 commits into
base: 12.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Use load
  • Loading branch information
timacdonald committed Apr 30, 2025
commit 4a24d3f60b163498513ed449debf225494fb4923
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/SerializesModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function __unserialize(array $values)
if (($value instanceof Model || $value instanceof Collection) && ($attributes = $property->getAttributes(LoadRelationships::class))) {
$relations = $attributes[0]->getArguments()[0];

$value->loadMissing($relations);
$value->load($relations);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Queue/ModelSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public function test_it_respects_with_relations_attribute_for_collections()
$this->assertTrue($unserialized->property->every->relationLoaded('roles'));
}

public function test_it_only_loads_missing_relationships()
public function test_it_reloads_already_loaded_relationships()
{
$user = User::create([
'email' => 'taylor@laravel.com',
Expand All @@ -433,7 +433,7 @@ public function test_it_only_loads_missing_relationships()
/** @var ModelSerializationLoadRelationships $unserialized */
$unserialized = unserialize($serialized);

$this->assertCount(2, $queries);
$this->assertCount(3, $queries);
$this->assertTrue($unserialized->property->relationLoaded('roles'));
}

Expand Down
Loading
0