Skip to content

Commit 2654359

Browse files
committed
Added 'usingComponent' method that allows you to pass a cell value to a component (Improved syntax)
1 parent 72ca151 commit 2654359

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Screen/Cell.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public function component(string $component, array $params = []): static
130130
/**
131131
* Pass only the cell value to the component
132132
*
133-
*
134133
* @throws \ReflectionException
135134
*
136135
* @return $this
@@ -140,6 +139,18 @@ public function asComponent(string $component, array $params = []): static
140139
return $this->render(fn ($value) => $this->renderComponent($component, $value->getContent($this->name), $params));
141140
}
142141

142+
/**
143+
* Pass only the cell value to the component
144+
*
145+
* @throws \ReflectionException
146+
*
147+
* @return $this
148+
*/
149+
public function usingComponent(string $component, ...$params): static
150+
{
151+
return $this->asComponent($component, $params);
152+
}
153+
143154
/**
144155
* @param Repository|Model $source
145156
*

tests/Unit/Screen/TDComponentAsValueTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ public function testTdArgumentView(): void
6464
$this->checkedArgument($view);
6565
}
6666

67+
public function testTdArgumentViewUsingComponent(): void
68+
{
69+
$view = TD::make('email')
70+
->usingComponent(SimpleShowValueWithArguments::class, from: 'Sasha')
71+
->buildTd($this->user);
72+
73+
$this->checkedArgument($view);
74+
}
75+
6776
public function testTdArgumentViewWithClosureArgument(): void
6877
{
6978
$view = TD::make('email')

0 commit comments

Comments
 (0)