Skip to content

Commit fe1de7a

Browse files
simonhampclaude
andcommitted
Fix Filament v5 Get/Set type hint namespace in resource forms
Update closures in Filament resource forms to use the new Filament\Schemas\Components\Utilities\Get and Set classes instead of the removed Filament\Forms\Get and Filament\Forms\Set. Fixes #46 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 664ca1a commit fe1de7a

File tree

6 files changed

+69
-7
lines changed

6 files changed

+69
-7
lines changed

app/Filament/Resources/ArticleResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use Filament\Forms\Components\MarkdownEditor;
1313
use Filament\Forms\Components\Textarea;
1414
use Filament\Forms\Components\TextInput;
15-
use Filament\Forms\Set;
1615
use Filament\Resources\Resource;
16+
use Filament\Schemas\Components\Utilities\Set;
1717
use Filament\Schemas\Schema;
1818
use Filament\Tables\Columns\TextColumn;
1919
use Filament\Tables\Table;

app/Filament/Resources/PluginBundleResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function form(Schema $schema): Schema
4242
->required()
4343
->maxLength(255)
4444
->live(onBlur: true)
45-
->afterStateUpdated(function (string $state, Forms\Set $set): void {
45+
->afterStateUpdated(function (string $state, Schemas\Components\Utilities\Set $set): void {
4646
$set('slug', Str::slug($state));
4747
}),
4848

app/Filament/Resources/ProductResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function form(Schema $schema): Schema
4040
->required()
4141
->maxLength(255)
4242
->live(onBlur: true)
43-
->afterStateUpdated(function (string $state, Forms\Set $set): void {
43+
->afterStateUpdated(function (string $state, Schemas\Components\Utilities\Set $set): void {
4444
$set('slug', Str::slug($state));
4545
}),
4646

app/Filament/Resources/ShowcaseResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function form(Schema $schema): Schema
7272
->live(),
7373

7474
Schemas\Components\Fieldset::make('Mobile Links')
75-
->visible(fn (Forms\Get $get) => $get('has_mobile'))
75+
->visible(fn (Schemas\Components\Utilities\Get $get) => $get('has_mobile'))
7676
->schema([
7777
Forms\Components\TextInput::make('app_store_url')
7878
->label('App Store URL')
@@ -86,7 +86,7 @@ public static function form(Schema $schema): Schema
8686
]),
8787

8888
Schemas\Components\Fieldset::make('Desktop Downloads')
89-
->visible(fn (Forms\Get $get) => $get('has_desktop'))
89+
->visible(fn (Schemas\Components\Utilities\Get $get) => $get('has_desktop'))
9090
->schema([
9191
Forms\Components\TextInput::make('windows_download_url')
9292
->label('Windows Download URL')

app/Filament/Resources/WallOfLoveSubmissionResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ public static function form(Schema $schema): Schema
8383
Forms\Components\Toggle::make('promoted')
8484
->label('Promoted to Homepage')
8585
->helperText('Promoted submissions appear in the feedback section on the homepage.')
86-
->visible(fn (Forms\Get $get) => $get('is_approved'))
86+
->visible(fn (Schemas\Components\Utilities\Get $get) => $get('is_approved'))
8787
->live(),
8888

8989
Forms\Components\Textarea::make('promoted_testimonial')
9090
->label('Promoted Testimonial (optional override)')
9191
->helperText('Leave empty to use the original testimonial, or enter a clipped version for the homepage.')
9292
->rows(4)
93-
->visible(fn (Forms\Get $get) => $get('is_approved') && $get('promoted')),
93+
->visible(fn (Schemas\Components\Utilities\Get $get) => $get('is_approved') && $get('promoted')),
9494
])
9595
->columns(1),
9696
]);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace Tests\Feature\Filament;
4+
5+
use App\Filament\Resources\WallOfLoveSubmissionResource\Pages\EditWallOfLoveSubmission;
6+
use App\Filament\Resources\WallOfLoveSubmissionResource\Pages\ListWallOfLoveSubmissions;
7+
use App\Models\User;
8+
use App\Models\WallOfLoveSubmission;
9+
use Illuminate\Foundation\Testing\RefreshDatabase;
10+
use Livewire\Livewire;
11+
use Tests\TestCase;
12+
13+
class WallOfLoveSubmissionResourceTest extends TestCase
14+
{
15+
use RefreshDatabase;
16+
17+
private User $admin;
18+
19+
protected function setUp(): void
20+
{
21+
parent::setUp();
22+
23+
$this->admin = User::factory()->create(['email' => 'admin@test.com']);
24+
config(['filament.users' => ['admin@test.com']]);
25+
}
26+
27+
public function test_list_page_renders_successfully(): void
28+
{
29+
WallOfLoveSubmission::factory()->count(3)->create();
30+
31+
Livewire::actingAs($this->admin)
32+
->test(ListWallOfLoveSubmissions::class)
33+
->assertSuccessful();
34+
}
35+
36+
public function test_edit_page_renders_for_approved_submission(): void
37+
{
38+
$submission = WallOfLoveSubmission::factory()->approved()->create();
39+
40+
Livewire::actingAs($this->admin)
41+
->test(EditWallOfLoveSubmission::class, ['record' => $submission->getRouteKey()])
42+
->assertSuccessful();
43+
}
44+
45+
public function test_edit_page_renders_for_pending_submission(): void
46+
{
47+
$submission = WallOfLoveSubmission::factory()->pending()->create();
48+
49+
Livewire::actingAs($this->admin)
50+
->test(EditWallOfLoveSubmission::class, ['record' => $submission->getRouteKey()])
51+
->assertSuccessful();
52+
}
53+
54+
public function test_edit_page_renders_for_promoted_submission(): void
55+
{
56+
$submission = WallOfLoveSubmission::factory()->approved()->promoted()->create();
57+
58+
Livewire::actingAs($this->admin)
59+
->test(EditWallOfLoveSubmission::class, ['record' => $submission->getRouteKey()])
60+
->assertSuccessful();
61+
}
62+
}

0 commit comments

Comments
 (0)