Skip to content

Commit 5810058

Browse files
committed
2 parents 552b4c2 + 0167c42 commit 5810058

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Forms/Components/NestedBuilder.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
namespace Thiktak\FilamentNestedBuilderForm\Forms\Components;
44

55
use Closure;
6-
use Filament\Forms\Components\Builder;
76
use Illuminate\Support\Collection;
87

98
class NestedBuilder extends NestedSubBuilder
109
{
11-
public Closure | null $nestedConfiguration = null;
10+
public ?Closure $nestedConfiguration = null;
11+
1212
protected array $nestedSchemas = [];
1313

1414
protected NestedSubBuilder $nestedSubBuilder;
1515

1616
public function nestedSchema(Closure $components, string $name = 'default'): static
1717
{
1818
$this->nestedSchemas[$name] = $components;
19+
1920
return $this;
2021
}
2122

@@ -33,7 +34,6 @@ public function getNestedSubBuilder(): NestedSubBuilder
3334
return $this->nestedSubBuilder ?? $this;
3435
}
3536

36-
3737
public function getNestedNamedChildComponents(string $name = 'default', string $fallbackName = 'default'): mixed
3838
{
3939
if (isset($this->nestedSchemas[$name])) {
@@ -45,7 +45,7 @@ public function getNestedNamedChildComponents(string $name = 'default', string $
4545
return [];
4646
}
4747

48-
public function nestedConfiguration(Closure | null $nestedConfiguration = null): static
48+
public function nestedConfiguration(Closure $nestedConfiguration = null): static
4949
{
5050
$this->nestedConfiguration = $nestedConfiguration;
5151

@@ -57,12 +57,12 @@ public function nestedConfiguration(Closure | null $nestedConfiguration = null):
5757
public function getNestedConfiguration(NestedSubBuilder $builder): static
5858
{
5959
$this->evaluate($this->nestedConfiguration, [
60-
'builder' => $builder ?: $this
60+
'builder' => $builder ?: $this,
6161
]);
62+
6263
return $this;
6364
}
6465

65-
6666
/*protected function getRootNestedBuilderIterator($data, $object): Collection
6767
{
6868
if (!is_object($object)) {

src/Forms/Components/NestedSubBuilder.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
class NestedSubBuilder extends Builder
88
{
99
public NestedBuilder $nestedBuilder;
10+
1011
public int $level = 1;
1112

1213
public function nestedBuilder(NestedBuilder $nestedBuilder): self
1314
{
1415
$this->nestedBuilder = $nestedBuilder;
16+
1517
return $this;
1618
}
1719

@@ -23,6 +25,7 @@ public function getNestedBuilder(): NestedBuilder
2325
public function level(int $level): self
2426
{
2527
$this->level = $level;
28+
2629
return $this;
2730
}
2831

@@ -31,16 +34,14 @@ public function getLevel(): int
3134
return $this->level;
3235
}
3336

34-
35-
3637
public function getChildComponents(): array
3738
{
38-
if (!$this->childComponents) {
39+
if (! $this->childComponents) {
3940
$this->childComponents(
4041
(array) $this->evaluate(
4142
$this->getNestedBuilder()->getNestedNamedChildComponents(),
4243
[
43-
'builder' => $this
44+
'builder' => $this,
4445
]
4546
)
4647
);
@@ -49,6 +50,7 @@ public function getChildComponents(): array
4950
if ($this->childComponents) {
5051
return parent::getChildComponents();
5152
}
53+
5254
return [];
5355
}
5456

@@ -70,14 +72,13 @@ public function importNestedBlocks($make, string $name = null): Builder
7072
->schema(fn () => $this->evaluate(
7173
$nestedComponents,
7274
[
73-
'builder' => $builder
75+
'builder' => $builder,
7476
]
7577
));
7678

7779
return $builder;
7880
}
7981

80-
8182
/*protected Collection $debug;
8283
protected int $level = 1;
8384
protected Closure | string | null $nestedDefinition = 'default';

0 commit comments

Comments
 (0)