This commit is contained in:
Ralph J. Smit
2025-02-10 19:07:37 +01:00
parent 5ecfab6a93
commit 29d8170e9f
2 changed files with 11 additions and 1 deletions
@@ -36,6 +36,7 @@ class Component extends ViewComponent
protected function resolveDefaultClosureDependencyForEvaluationByName(string $parameterName): array
{
return match ($parameterName) {
'livewire' => [$this->getLivewire()],
'record' => [$this->getRecord()],
'state' => [$this->getState()],
default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName),
+10 -1
View File
@@ -14,7 +14,9 @@ it('can inject the correct `$livewire` for infolists outside a panel', function
->assertSee('First Entry Label')
->assertSee('First Entry State')
->assertSee('Second Entry Label')
->assertSee('Second Entry State');
->assertSee('Second Entry State')
->assertSee('Third Entry Label')
->assertSee('Third Entry State (dynamic)');
});
class TestComponentWithInfolist extends Livewire
@@ -51,6 +53,13 @@ class TestComponentWithInfolist extends Livewire
return [
Infolists\Components\TextEntry::make('second_entry')
->label('Second Entry Label'),
Infolists\Components\TextEntry::make('third_entry')
->label('Third Entry Label')
->getStateUsing(function (TestComponentWithInfolist $livewire) {
expect($livewire)->toBe($this);
return 'Third Entry State (dynamic)';
}),
];
});
}