22
33namespace App \Filament \Resources ;
44
5+ use Filament \Schemas \Schema ;
6+ use Filament \Forms \Components \TextInput ;
7+ use Filament \Forms \Components \Textarea ;
8+ use Filament \Forms \Components \Toggle ;
9+ use Filament \Tables \Columns \TextColumn ;
10+ use Filament \Tables \Columns \IconColumn ;
11+ use Filament \Tables \Filters \TernaryFilter ;
12+ use Filament \Actions \Action ;
13+ use Filament \Actions \ViewAction ;
14+ use Filament \Actions \BulkActionGroup ;
15+ use Filament \Actions \BulkAction ;
16+ use App \Filament \Resources \Pages \ListModules ;
17+ use App \Filament \Resources \Pages \ViewModule ;
518use App \Modules \ModuleManager ;
619use Filament \Forms ;
7- use Filament \Forms \Form ;
820use Filament \Resources \Resource ;
921use Filament \Tables ;
1022use Filament \Tables \Table ;
@@ -15,24 +27,24 @@ class ModuleResource extends Resource
1527{
1628 protected static ?string $ model = null ;
1729
18- protected static ? string $ navigationIcon = 'heroicon-o-puzzle-piece ' ;
30+ protected static string | \ BackedEnum | null $ navigationIcon = 'heroicon-o-puzzle-piece ' ;
1931
20- protected static ? string $ navigationGroup = 'System ' ;
32+ protected static string | \ UnitEnum | null $ navigationGroup = 'System ' ;
2133
2234 protected static ?string $ navigationLabel = 'Modules ' ;
2335
24- public static function form (Form $ form ): Form
36+ public static function form (Schema $ schema ): Schema
2537 {
26- return $ form
27- ->schema ([
28- Forms \ Components \ TextInput::make ('name ' )
38+ return $ schema
39+ ->components ([
40+ TextInput::make ('name ' )
2941 ->required ()
3042 ->disabled (),
31- Forms \ Components \ TextInput::make ('version ' )
43+ TextInput::make ('version ' )
3244 ->disabled (),
33- Forms \ Components \ Textarea::make ('description ' )
45+ Textarea::make ('description ' )
3446 ->disabled (),
35- Forms \ Components \ Toggle::make ('enabled ' )
47+ Toggle::make ('enabled ' )
3648 ->required (),
3749 ]);
3850 }
@@ -42,25 +54,25 @@ public static function table(Table $table): Table
4254 return $ table
4355 ->query (static ::getEloquentQuery ())
4456 ->columns ([
45- Tables \ Columns \ TextColumn::make ('name ' )
57+ TextColumn::make ('name ' )
4658 ->searchable ()
4759 ->sortable (),
48- Tables \ Columns \ TextColumn::make ('version ' )
60+ TextColumn::make ('version ' )
4961 ->sortable (),
50- Tables \ Columns \ TextColumn::make ('description ' )
62+ TextColumn::make ('description ' )
5163 ->limit (50 ),
52- Tables \ Columns \ IconColumn::make ('enabled ' )
64+ IconColumn::make ('enabled ' )
5365 ->boolean ()
5466 ->trueIcon ('heroicon-o-check-circle ' )
5567 ->falseIcon ('heroicon-o-x-circle ' )
5668 ->trueColor ('success ' )
5769 ->falseColor ('danger ' ),
58- Tables \ Columns \ TextColumn::make ('dependencies ' )
70+ TextColumn::make ('dependencies ' )
5971 ->formatStateUsing (fn ($ state ) => is_array ($ state ) ? implode (', ' , $ state ) : $ state )
6072 ->limit (30 ),
6173 ])
6274 ->filters ([
63- Tables \ Filters \ TernaryFilter::make ('enabled ' )
75+ TernaryFilter::make ('enabled ' )
6476 ->label ('Status ' )
6577 ->trueLabel ('Enabled ' )
6678 ->falseLabel ('Disabled ' )
@@ -69,8 +81,8 @@ public static function table(Table $table): Table
6981 false: fn (Builder $ query ) => $ query ->where ('enabled ' , false ),
7082 ),
7183 ])
72- ->actions ([
73- Tables \ Actions \ Action::make ('toggle ' )
84+ ->recordActions ([
85+ Action::make ('toggle ' )
7486 ->label (fn ($ record ) => $ record ->enabled ? 'Disable ' : 'Enable ' )
7587 ->icon (fn ($ record ) => $ record ->enabled ? 'heroicon-o-x-circle ' : 'heroicon-o-check-circle ' )
7688 ->color (fn ($ record ) => $ record ->enabled ? 'danger ' : 'success ' )
@@ -84,7 +96,7 @@ public static function table(Table $table): Table
8496 }
8597 })
8698 ->requiresConfirmation (),
87- Tables \ Actions \ Action::make ('install ' )
99+ Action::make ('install ' )
88100 ->label ('Install ' )
89101 ->icon ('heroicon-o-arrow-down-tray ' )
90102 ->color ('info ' )
@@ -94,7 +106,7 @@ public static function table(Table $table): Table
94106 })
95107 ->visible (fn ($ record ) => !$ record ->enabled )
96108 ->requiresConfirmation (),
97- Tables \ Actions \ Action::make ('uninstall ' )
109+ Action::make ('uninstall ' )
98110 ->label ('Uninstall ' )
99111 ->icon ('heroicon-o-trash ' )
100112 ->color ('danger ' )
@@ -104,11 +116,11 @@ public static function table(Table $table): Table
104116 })
105117 ->visible (fn ($ record ) => $ record ->enabled )
106118 ->requiresConfirmation (),
107- Tables \ Actions \ ViewAction::make (),
119+ ViewAction::make (),
108120 ])
109- ->bulkActions ([
110- Tables \ Actions \ BulkActionGroup::make ([
111- Tables \ Actions \ BulkAction::make ('enable ' )
121+ ->toolbarActions ([
122+ BulkActionGroup::make ([
123+ BulkAction::make ('enable ' )
112124 ->label ('Enable Selected ' )
113125 ->icon ('heroicon-o-check-circle ' )
114126 ->color ('success ' )
@@ -119,7 +131,7 @@ public static function table(Table $table): Table
119131 }
120132 })
121133 ->requiresConfirmation (),
122- Tables \ Actions \ BulkAction::make ('disable ' )
134+ BulkAction::make ('disable ' )
123135 ->label ('Disable Selected ' )
124136 ->icon ('heroicon-o-x-circle ' )
125137 ->color ('danger ' )
@@ -179,8 +191,8 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
179191 public static function getPages (): array
180192 {
181193 return [
182- 'index ' => Pages \ ListModules::route ('/ ' ),
183- 'view ' => Pages \ ViewModule::route ('/{record} ' ),
194+ 'index ' => ListModules::route ('/ ' ),
195+ 'view ' => ViewModule::route ('/{record} ' ),
184196 ];
185197 }
186198}
0 commit comments