Skip to content

Commit 515cd83

Browse files
committed
Initial filament v4
1 parent 3c988f2 commit 515cd83

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
}
2222
],
2323
"require": {
24-
"php": "^8.1",
24+
"php": "^8.2",
2525
"filament/forms": "^3.0",
2626
"spatie/laravel-package-tools": "^1.15.0",
2727
"illuminate/contracts": "^10.0|^11.0|^12.0"
2828
},
2929
"require-dev": {
30-
"nunomaduro/collision": "^7.9",
30+
"nunomaduro/collision": "^7.9||^8.0",
3131
"orchestra/testbench": "^8.0|^9.0|^10.0",
3232
"pestphp/pest": "^2.0|^3.7",
3333
"pestphp/pest-plugin-arch": "^2.0|^3.0",
@@ -62,6 +62,6 @@
6262
]
6363
}
6464
},
65-
"minimum-stability": "dev",
65+
"minimum-stability": "beta",
6666
"prefer-stable": true
6767
}

src/SelectTree.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
namespace CodeWithDennis\FilamentSelectTree;
44

5+
use Filament\Schemas\Components\Contracts\HasAffixActions;
6+
use Filament\Schemas\Components\Concerns\CanBeDisabled;
7+
use Filament\Schemas\Components\Concerns\HasActions;
8+
use Filament\Schemas\Schema;
9+
use Filament\Actions\Action;
10+
use InvalidArgumentException;
511
use Closure;
612
use Exception;
7-
use Filament\Forms\ComponentContainer;
8-
use Filament\Forms\Components\Actions\Action;
9-
use Filament\Forms\Components\Concerns\CanBeDisabled;
1013
use Filament\Forms\Components\Concerns\CanBeSearchable;
11-
use Filament\Forms\Components\Concerns\HasActions;
1214
use Filament\Forms\Components\Concerns\HasAffixes;
1315
use Filament\Forms\Components\Concerns\HasPivotData;
1416
use Filament\Forms\Components\Concerns\HasPlaceholder;
15-
use Filament\Forms\Components\Contracts\HasAffixActions;
1617
use Filament\Forms\Components\Field;
17-
use Filament\Forms\Form;
1818
use Filament\Support\Facades\FilamentIcon;
1919
use Illuminate\Database\Eloquent\Relations\BelongsTo;
2020
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -130,12 +130,12 @@ protected function setUp(): void
130130
}
131131
});
132132

133-
$this->createOptionUsing(static function (SelectTree $component, array $data, Form $form) {
133+
$this->createOptionUsing(static function (SelectTree $component, array $data, Schema $schema) {
134134
$record = $component->getRelationship()->getRelated();
135135
$record->fill($data);
136136
$record->save();
137137

138-
$form->model($record)->saveRelationships();
138+
$schema->model($record)->saveRelationships();
139139

140140
return $component->getCustomKey($record);
141141
});
@@ -310,7 +310,7 @@ public function prepend(Closure|array|null $prepend = null): static
310310
if (is_array($this->prepend) && isset($this->prepend['name'], $this->prepend['value'])) {
311311
$this->prepend['value'] = (string) $this->prepend['value'];
312312
} else {
313-
throw new \InvalidArgumentException('The provided prepend value must be an array with "name" and "value" keys.');
313+
throw new InvalidArgumentException('The provided prepend value must be an array with "name" and "value" keys.');
314314
}
315315

316316
return $this;
@@ -510,9 +510,9 @@ public function getHiddenOptions(): array
510510
return $this->evaluate($this->hiddenOptions);
511511
}
512512

513-
public function getCreateOptionActionForm(Form $form): array|Form|null
513+
public function getCreateOptionActionForm(Schema $schema): array|Schema|null
514514
{
515-
return $this->evaluate($this->createOptionActionForm, ['form' => $form]);
515+
return $this->evaluate($this->createOptionActionForm, ['form' => $schema]);
516516
}
517517

518518
public function hasCreateOptionActionFormSchema(): bool
@@ -560,19 +560,19 @@ public function getCreateOptionAction(): ?Action
560560
}
561561

562562
$action = Action::make($this->getCreateOptionActionName())
563-
->form(function (SelectTree $component, Form $form): array|Form|null {
564-
return $component->getCreateOptionActionForm($form->model(
563+
->schema(function (SelectTree $component, Schema $schema): array|Schema|null {
564+
return $component->getCreateOptionActionForm($schema->model(
565565
$component->getRelationship() ? $component->getRelationship()->getModel()::class : null,
566566
));
567567
})
568-
->action(static function (Action $action, array $arguments, SelectTree $component, array $data, ComponentContainer $form) {
568+
->action(static function (Action $action, array $arguments, SelectTree $component, array $data, Schema $schema) {
569569
if (! $component->getCreateOptionUsing()) {
570570
throw new Exception("Select field [{$component->getStatePath()}] must have a [createOptionUsing()] closure set.");
571571
}
572572

573573
$createdOptionKey = $component->evaluate($component->getCreateOptionUsing(), [
574574
'data' => $data,
575-
'form' => $form,
575+
'form' => $schema,
576576
]);
577577

578578
$state = $component->getMultiple()
@@ -591,7 +591,7 @@ public function getCreateOptionAction(): ?Action
591591

592592
$action->callAfter();
593593

594-
$form->fill();
594+
$schema->fill();
595595

596596
$action->halt();
597597
})

0 commit comments

Comments
 (0)