8
8
use App \Models \Channel ;
9
9
use Filament \Forms ;
10
10
use Filament \Forms \Form ;
11
- use Filament \Forms \Get ;
12
- use Filament \Forms \Set ;
13
11
use Filament \Resources \Resource ;
12
+ use Filament \Support \Enums \MaxWidth ;
14
13
use Filament \Tables ;
15
14
use Filament \Tables \Actions \ActionGroup ;
16
15
use Filament \Tables \Table ;
@@ -23,28 +22,37 @@ final class ChannelResource extends Resource
23
22
24
23
protected static ?string $ navigationIcon = 'heroicon-o-queue-list ' ;
25
24
25
+ public static function getLabel (): string
26
+ {
27
+ return __ ('Channels ' );
28
+ }
29
+
26
30
public static function form (Form $ form ): Form
27
31
{
28
32
return $ form
29
33
->schema ([
30
- Forms \Components \TextInput::make ('name ' )
31
- ->required ()
32
- ->live (onBlur: true )
33
- ->afterStateUpdated (function (Get $ get , Set $ set , ?string $ old , ?string $ state ): void {
34
- if (($ get ('slug ' ) ?? '' ) !== Str::slug ($ old )) {
35
- return ;
36
- }
37
-
38
- $ set ('slug ' , Str::slug ($ state ));
39
- }),
40
- Forms \Components \TextInput::make ('slug ' )
41
- ->required (),
42
- Forms \Components \Select::make ('parent_id ' )
43
- ->relationship ('parent ' , 'name ' , modifyQueryUsing: fn (Builder $ query ) => $ query ->whereNull ('parent_id ' ))
44
- ->default (null ),
45
- Forms \Components \TextInput::make ('color ' )
46
- ->maxLength (255 )
47
- ->type ('color ' ),
34
+ Forms \Components \Section::make ()
35
+ ->schema ([
36
+ Forms \Components \TextInput::make ('name ' )
37
+ ->required ()
38
+ ->live (onBlur: true )
39
+ ->afterStateUpdated (function (string $ operation , $ state , Forms \Set $ set ): void {
40
+ $ set ('slug ' , Str::slug ($ state ));
41
+ }),
42
+ Forms \Components \TextInput::make ('slug ' )
43
+ ->readOnly ()
44
+ ->helperText (__ ('Cette valeur est générée dynamiquement en fonction du Name. ' )),
45
+ Forms \Components \Select::make ('parent_id ' )
46
+ ->relationship ('parent ' , 'name ' , fn (Builder $ query ) => $ query ->whereNull ('parent_id ' ))
47
+ ->default (null ),
48
+ Forms \Components \TextInput::make ('color ' )
49
+ ->maxLength (255 )
50
+ ->type ('color ' ),
51
+ Forms \Components \Textarea::make ('description.fr ' )
52
+ ->label ('Description ' )
53
+ ->columnSpanFull (),
54
+ ])
55
+ ->columnSpan (['lg ' => 2 ]),
48
56
]);
49
57
}
50
58
@@ -59,25 +67,25 @@ public static function table(Table $table): Table
59
67
Tables \Columns \TextColumn::make ('parent.name ' )
60
68
->numeric ()
61
69
->sortable (),
70
+ Tables \Columns \TextColumn::make ('thread_number ' )
71
+ ->label ('Nombre de thead ' )
72
+ ->getStateUsing (fn ($ record ) => $ record ->threads ()->count ()),
62
73
Tables \Columns \TextColumn::make ('color ' )
63
74
->searchable (),
64
75
Tables \Columns \TextColumn::make ('created_at ' )
65
76
->dateTime ()
66
77
->sortable ()
67
78
->toggleable (isToggledHiddenByDefault: true ),
68
- Tables \Columns \TextColumn::make ('updated_at ' )
69
- ->dateTime ()
70
- ->sortable ()
71
- ->toggleable (isToggledHiddenByDefault: true ),
72
79
])
73
80
->filters ([
74
- //
81
+
75
82
])
76
83
->actions ([
77
84
ActionGroup::make ([
78
85
Tables \Actions \DeleteAction::make (),
79
86
Tables \Actions \EditAction::make ()
80
- ->color ('warning ' ),
87
+ ->slideOver ()
88
+ ->modalWidth (MaxWidth::Large),
81
89
]),
82
90
])
83
91
->bulkActions ([
@@ -91,8 +99,6 @@ public static function getPages(): array
91
99
{
92
100
return [
93
101
'index ' => Pages \ListChannels::route ('/ ' ),
94
- 'create ' => Pages \CreateChannel::route ('/create ' ),
95
- 'edit ' => Pages \EditChannel::route ('/{record}/edit ' ),
96
102
];
97
103
}
98
104
}
0 commit comments