4
4
5
5
use App \Filament \Resources \PluginUserResource \Pages ;
6
6
use App \Filament \Resources \PluginUserResource \RelationManagers ;
7
+ use App \Http \Resources \PluginUserResource \Pages \CreatePluginUser ;
8
+ use App \Http \Resources \PluginUserResource \Pages \EditPluginUser ;
9
+ use App \Http \Resources \PluginUserResource \Pages \ListPluginUsers ;
10
+ use App \Http \Resources \PluginUserResource \Widgets \ActiveChart ;
7
11
use App \Models \PluginUser ;
8
12
use Filament \Forms ;
9
13
use Filament \Forms \Components \Actions \Action ;
10
14
use Filament \Resources \Form ;
11
15
use Filament \Resources \Resource ;
12
16
use Filament \Resources \Table ;
13
17
use Filament \Tables ;
18
+ use Filament \Widgets \ChartWidget ;
14
19
use Illuminate \Database \Eloquent \Builder ;
15
20
16
21
class PluginUserResource extends Resource
@@ -24,57 +29,6 @@ class PluginUserResource extends Resource
24
29
25
30
protected static ?string $ navigationIcon = 'heroicon-o-users ' ;
26
31
27
- public static function form (Form $ form ): Form
28
- {
29
- return $ form
30
- ->schema ([
31
- Forms \Components \Card::make (array (
32
- Forms \Components \TextInput::make ('name ' )
33
- ->maxLength (20 )
34
- ->placeholder ("Name of user's plugin " ),
35
- Forms \Components \TextInput::make ('version ' )
36
- ->required ()
37
- ->mask (fn (Forms \Components \TextInput \Mask $ mask ) => $ mask ->pattern ('0.0.0 ' ))
38
- ->maxLength (10 )
39
- ->placeholder ('current version of plugin ' ),
40
- Forms \Components \TextInput::make ('website ' )
41
- ->url ()
42
- ->suffixAction (fn (?string $ state ): Action =>
43
- Action::make ('visit ' )
44
- ->icon ('heroicon-s-external-link ' )
45
- ->url (
46
- filled ($ state ) ? "https:// {$ state }" : null ,
47
- shouldOpenInNewTab: true ,
48
- ),
49
- )
50
- ->maxLength (100 )
51
- ->placeholder ('User website ' ),
52
- ))->columns (3 ),
53
- Forms \Components \Card::make ([
54
- Forms \Components \KeyValue::make ('plugins ' )
55
- ->keyLabel ('# ' )
56
- ->disableEditingKeys (true )
57
- ->valueLabel ('Name ' ),
58
- Forms \Components \KeyValue::make ('server ' )
59
- ->keyLabel ('# ' )
60
- ->disableEditingKeys (true )
61
- ->valueLabel ('Software ' ),
62
- ])->columns (),
63
-
64
- Forms \Components \Card::make ([
65
- Forms \Components \DatePicker::make ('activated_at ' )
66
- ->required ()
67
- ->placeholder ('month day, year ' ),
68
- Forms \Components \DatePicker::make ('deactivated_at ' )
69
- ->placeholder ('month day, year ' ),
70
- Forms \Components \DatePicker::make ('uninstalled_at ' )
71
- ->placeholder ('month day, year ' ),
72
- Forms \Components \Radio::make ('status ' )
73
- ->options (self ::STATUS_ARRAY ),
74
- ])->columns (3 ),
75
- ]);
76
- }
77
-
78
32
public static function table (Table $ table ): Table
79
33
{
80
34
return $ table
@@ -130,6 +84,56 @@ public static function table(Table $table): Table
130
84
]);
131
85
}
132
86
87
+ public static function form (Form $ form ): Form
88
+ {
89
+ return $ form
90
+ ->schema ([
91
+ Forms \Components \Card::make (array (
92
+ Forms \Components \TextInput::make ('name ' )
93
+ ->maxLength (20 )
94
+ ->placeholder ("Name of user's plugin " ),
95
+ Forms \Components \TextInput::make ('version ' )
96
+ ->required ()
97
+ ->mask (fn (Forms \Components \TextInput \Mask $ mask ) => $ mask ->pattern ('0.0.0 ' ))
98
+ ->maxLength (10 )
99
+ ->placeholder ('current version of plugin ' ),
100
+ Forms \Components \TextInput::make ('website ' )
101
+ ->url ()
102
+ ->suffixAction (fn (?string $ state ): Action => Action::make ('visit ' )
103
+ ->icon ('heroicon-s-external-link ' )
104
+ ->url (
105
+ filled ($ state ) ? "https:// {$ state }" : null ,
106
+ shouldOpenInNewTab: true ,
107
+ ),
108
+ )
109
+ ->maxLength (100 )
110
+ ->placeholder ('User website ' ),
111
+ ))->columns (3 ),
112
+ Forms \Components \Card::make ([
113
+ Forms \Components \KeyValue::make ('plugins ' )
114
+ ->keyLabel ('# ' )
115
+ ->disableEditingKeys (true )
116
+ ->valueLabel ('Name ' ),
117
+ Forms \Components \KeyValue::make ('server ' )
118
+ ->keyLabel ('# ' )
119
+ ->disableEditingKeys (true )
120
+ ->valueLabel ('Software ' ),
121
+ ])->columns (),
122
+
123
+ Forms \Components \Card::make ([
124
+ Forms \Components \DatePicker::make ('activated_at ' )
125
+ ->required ()
126
+ ->placeholder ('month day, year ' ),
127
+ Forms \Components \DatePicker::make ('deactivated_at ' )
128
+ ->placeholder ('month day, year ' ),
129
+ Forms \Components \DatePicker::make ('uninstalled_at ' )
130
+ ->placeholder ('month day, year ' ),
131
+ Forms \Components \Radio::make ('status ' )
132
+ ->options (self ::STATUS_ARRAY ),
133
+ ])->columns (3 ),
134
+ ]);
135
+ }
136
+
133
137
public static function getRelations (): array
134
138
{
135
139
return [
@@ -140,9 +144,18 @@ public static function getRelations(): array
140
144
public static function getPages (): array
141
145
{
142
146
return [
143
- 'index ' => \App \Http \Resources \PluginUserResource \Pages \ListPluginUsers::route ('/ ' ),
144
- 'create ' => \App \Http \Resources \PluginUserResource \Pages \CreatePluginUser::route ('/create ' ),
145
- 'edit ' => \App \Http \Resources \PluginUserResource \Pages \EditPluginUser::route ('/{record}/edit ' ),
147
+ 'index ' => ListPluginUsers::route ('/ ' ),
148
+ 'create ' => CreatePluginUser::route ('/create ' ),
149
+ 'edit ' => EditPluginUser::route ('/{record}/edit ' ),
150
+ ];
151
+ }
152
+
153
+ public static function getWidgets (): array
154
+ {
155
+ return [
156
+ ActiveChart::class,
146
157
];
147
158
}
159
+
160
+
148
161
}
0 commit comments