2
2
3
3
namespace App \Filament \App \Resources ;
4
4
5
+ use Filament \Schemas \Components \Tabs ;
6
+ use Filament \Schemas \Components \Tabs \Tab ;
7
+ use Str ;
8
+ use Filament \Forms \Components \Toggle ;
9
+ use Filament \Forms \Components \TagsInput ;
10
+ use Filament \Forms \Components \Repeater ;
11
+ use Filament \Tables \Columns \IconColumn ;
12
+ use Filament \Tables \Filters \SelectFilter ;
13
+ use Filament \Tables \Filters \Filter ;
14
+ use Filament \Actions \ActionGroup ;
15
+ use Filament \Actions \ViewAction ;
16
+ use Filament \Actions \Action ;
17
+ use Filament \Actions \DeleteAction ;
18
+ use Filament \Actions \BulkAction ;
5
19
use Filament \Actions \EditAction ;
6
20
use Filament \Actions \BulkActionGroup ;
7
21
use Filament \Actions \DeleteBulkAction ;
24
38
use Filament \Forms \Components \DateTimePicker ;
25
39
use Filament \Forms \Components \FileUpload ;
26
40
use Filament \Forms \Components \Section ;
27
- use Filament \Forms \Components \Tabs ;
28
41
use Illuminate \Database \Eloquent \Builder ;
29
42
use Illuminate \Database \Eloquent \SoftDeletingScope ;
30
43
use App \Filament \App \Resources \ContentResource \Pages ;
@@ -42,14 +55,14 @@ public static function form(Schema $schema): Schema
42
55
->components ([
43
56
Tabs::make ('Content ' )
44
57
->tabs ([
45
- Tabs \ Tab::make ('Content ' )
58
+ Tab::make ('Content ' )
46
59
->schema ([
47
60
TextInput::make ('title ' )
48
61
->required ()
49
62
->maxLength (255 )
50
63
->live (onBlur: true )
51
64
->afterStateUpdated (fn (string $ context , $ state , callable $ set ) =>
52
- $ context === 'create ' ? $ set ('slug ' , \ Str::slug ($ state )) : null
65
+ $ context === 'create ' ? $ set ('slug ' , Str::slug ($ state )) : null
53
66
),
54
67
55
68
TextInput::make ('slug ' )
@@ -89,7 +102,7 @@ public static function form(Schema $schema): Schema
89
102
->directory ('featured-images ' ),
90
103
]),
91
104
92
- Tabs \ Tab::make ('SEO ' )
105
+ Tab::make ('SEO ' )
93
106
->schema ([
94
107
TextInput::make ('seo_title ' )
95
108
->label ('SEO Title ' )
@@ -111,7 +124,7 @@ public static function form(Schema $schema): Schema
111
124
->url (),
112
125
]),
113
126
114
- Tabs \ Tab::make ('Settings ' )
127
+ Tab::make ('Settings ' )
115
128
->schema ([
116
129
Select::make ('workflow_status ' )
117
130
->options ([
@@ -147,17 +160,17 @@ public static function form(Schema $schema): Schema
147
160
])
148
161
->default ('default ' ),
149
162
150
- Forms \ Components \ Toggle::make ('is_featured ' )
163
+ Toggle::make ('is_featured ' )
151
164
->label ('Featured Content ' ),
152
165
153
- Forms \ Components \ Toggle::make ('is_sticky ' )
166
+ Toggle::make ('is_sticky ' )
154
167
->label ('Sticky Post ' ),
155
168
156
- Forms \ Components \ Toggle::make ('allow_comments ' )
169
+ Toggle::make ('allow_comments ' )
157
170
->label ('Allow Comments ' )
158
171
->default (true ),
159
172
160
- Forms \ Components \ Toggle::make ('password_protected ' )
173
+ Toggle::make ('password_protected ' )
161
174
->label ('Password Protected ' )
162
175
->reactive (),
163
176
@@ -167,18 +180,18 @@ public static function form(Schema $schema): Schema
167
180
->visible (fn (callable $ get ) => $ get ('password_protected ' )),
168
181
]),
169
182
170
- Tabs \ Tab::make ('Advanced ' )
183
+ Tab::make ('Advanced ' )
171
184
->schema ([
172
185
Textarea::make ('excerpt ' )
173
186
->label ('Custom Excerpt ' )
174
187
->rows (3 )
175
188
->helperText ('Leave empty to auto-generate from content ' ),
176
189
177
- Forms \ Components \ TagsInput::make ('tags ' )
190
+ TagsInput::make ('tags ' )
178
191
->label ('Tags ' )
179
192
->separator (', ' ),
180
193
181
- Forms \ Components \ Repeater::make ('custom_fields ' )
194
+ Repeater::make ('custom_fields ' )
182
195
->label ('Custom Fields ' )
183
196
->schema ([
184
197
TextInput::make ('key ' )
@@ -253,10 +266,10 @@ public static function table(Table $table): Table
253
266
->label ('Score ' )
254
267
->formatStateUsing (fn ($ state ) => $ state ? round ($ state ) . '% ' : 'N/A ' )
255
268
->color (fn ($ state ) => $ state >= 80 ? 'success ' : ($ state >= 60 ? 'warning ' : 'danger ' )),
256
- Tables \ Columns \ IconColumn::make ('is_featured ' )
269
+ IconColumn::make ('is_featured ' )
257
270
->boolean ()
258
271
->label ('Featured ' ),
259
- Tables \ Columns \ IconColumn::make ('is_sticky ' )
272
+ IconColumn::make ('is_sticky ' )
260
273
->boolean ()
261
274
->label ('Sticky ' ),
262
275
TextColumn::make ('published_at ' )
@@ -269,7 +282,7 @@ public static function table(Table $table): Table
269
282
->toggleable (isToggledHiddenByDefault: true ),
270
283
])
271
284
->filters ([
272
- Tables \ Filters \ SelectFilter::make ('workflow_status ' )
285
+ SelectFilter::make ('workflow_status ' )
273
286
->options ([
274
287
'draft ' => 'Draft ' ,
275
288
'review ' => 'In Review ' ,
@@ -278,45 +291,45 @@ public static function table(Table $table): Table
278
291
'scheduled ' => 'Scheduled ' ,
279
292
'rejected ' => 'Rejected ' ,
280
293
]),
281
- Tables \ Filters \ SelectFilter::make ('type ' )
294
+ SelectFilter::make ('type ' )
282
295
->options ([
283
296
'post ' => 'Post ' ,
284
297
'page ' => 'Page ' ,
285
298
'news ' => 'News ' ,
286
299
'blog ' => 'Blog ' ,
287
300
]),
288
- Tables \ Filters \ SelectFilter::make ('author ' )
301
+ SelectFilter::make ('author ' )
289
302
->relationship ('author ' , 'name ' ),
290
- Tables \ Filters \ SelectFilter::make ('category ' )
303
+ SelectFilter::make ('category ' )
291
304
->relationship ('category ' , 'name ' ),
292
- Tables \ Filters \ Filter::make ('is_featured ' )
305
+ Filter::make ('is_featured ' )
293
306
->query (fn (Builder $ query ): Builder => $ query ->where ('is_featured ' , true ))
294
307
->label ('Featured Only ' ),
295
- Tables \ Filters \ Filter::make ('is_sticky ' )
308
+ Filter::make ('is_sticky ' )
296
309
->query (fn (Builder $ query ): Builder => $ query ->where ('is_sticky ' , true ))
297
310
->label ('Sticky Only ' ),
298
- Tables \ Filters \ Filter::make ('published_today ' )
311
+ Filter::make ('published_today ' )
299
312
->query (fn (Builder $ query ): Builder => $ query ->whereDate ('published_at ' , today ()))
300
313
->label ('Published Today ' ),
301
- Tables \ Filters \ Filter::make ('published_this_week ' )
314
+ Filter::make ('published_this_week ' )
302
315
->query (fn (Builder $ query ): Builder => $ query ->whereBetween ('published_at ' , [now ()->startOfWeek (), now ()->endOfWeek ()]))
303
316
->label ('Published This Week ' ),
304
317
])
305
318
->recordActions ([
306
- Tables \ Actions \ ActionGroup::make ([
307
- Tables \ Actions \ ViewAction::make (),
308
- Tables \ Actions \ EditAction::make (),
309
- Tables \ Actions \ Action::make ('publish ' )
319
+ ActionGroup::make ([
320
+ ViewAction::make (),
321
+ EditAction::make (),
322
+ Action::make ('publish ' )
310
323
->icon ('heroicon-o-eye ' )
311
324
->color ('success ' )
312
325
->action (fn (Content $ record ) => $ record ->publish ())
313
326
->visible (fn (Content $ record ) => !$ record ->isPublished ()),
314
- Tables \ Actions \ Action::make ('feature ' )
327
+ Action::make ('feature ' )
315
328
->icon ('heroicon-o-star ' )
316
329
->color ('warning ' )
317
330
->action (fn (Content $ record ) => $ record ->update (['is_featured ' => !$ record ->is_featured ]))
318
331
->label (fn (Content $ record ) => $ record ->is_featured ? 'Unfeature ' : 'Feature ' ),
319
- Tables \ Actions \ Action::make ('duplicate ' )
332
+ Action::make ('duplicate ' )
320
333
->icon ('heroicon-o-document-duplicate ' )
321
334
->action (function (Content $ record ) {
322
335
$ newContent = $ record ->replicate ();
@@ -326,30 +339,30 @@ public static function table(Table $table): Table
326
339
$ newContent ->published_at = null ;
327
340
$ newContent ->save ();
328
341
}),
329
- Tables \ Actions \ DeleteAction::make (),
342
+ DeleteAction::make (),
330
343
]),
331
344
])
332
- ->bulkActions ([
333
- Tables \ Actions \ BulkActionGroup::make ([
334
- Tables \ Actions \ DeleteBulkAction::make (),
335
- Tables \ Actions \ BulkAction::make ('publish ' )
345
+ ->toolbarActions ([
346
+ BulkActionGroup::make ([
347
+ DeleteBulkAction::make (),
348
+ BulkAction::make ('publish ' )
336
349
->icon ('heroicon-o-eye ' )
337
350
->color ('success ' )
338
351
->action (fn (Collection $ records ) => $ records ->each ->publish ())
339
352
->deselectRecordsAfterCompletion (),
340
- Tables \ Actions \ BulkAction::make ('feature ' )
353
+ BulkAction::make ('feature ' )
341
354
->icon ('heroicon-o-star ' )
342
355
->color ('warning ' )
343
356
->action (fn (Collection $ records ) => Content::bulkFeature ($ records ->pluck ('id ' )->toArray (), true ))
344
357
->deselectRecordsAfterCompletion (),
345
- Tables \ Actions \ BulkAction::make ('unfeature ' )
358
+ BulkAction::make ('unfeature ' )
346
359
->icon ('heroicon-o-star ' )
347
360
->color ('gray ' )
348
361
->action (fn (Collection $ records ) => Content::bulkFeature ($ records ->pluck ('id ' )->toArray (), false ))
349
362
->deselectRecordsAfterCompletion (),
350
- Tables \ Actions \ BulkAction::make ('change_status ' )
363
+ BulkAction::make ('change_status ' )
351
364
->icon ('heroicon-o-pencil-square ' )
352
- ->form ([
365
+ ->schema ([
353
366
Select::make ('workflow_status ' )
354
367
->options ([
355
368
'draft ' => 'Draft ' ,
0 commit comments