File tree Expand file tree Collapse file tree 1 file changed +35
-10
lines changed Expand file tree Collapse file tree 1 file changed +35
-10
lines changed Original file line number Diff line number Diff line change 7
7
use App \Actions \Article \ApprovedArticleAction ;
8
8
use App \Filament \Resources \ArticleResource \Pages ;
9
9
use App \Models \Article ;
10
+ use Awcodes \FilamentBadgeableColumn \Components \Badge ;
11
+ use Awcodes \FilamentBadgeableColumn \Components \BadgeableColumn ;
10
12
use Filament \Resources \Resource ;
11
13
use Filament \Support \Enums \MaxWidth ;
12
14
use Filament \Tables ;
@@ -67,16 +69,39 @@ public static function table(Table $table): Table
67
69
->label ('Soumission ' )
68
70
->placeholder ('N/A ' )
69
71
->date (),
70
- Tables \Columns \TextColumn::make ('approved_at ' )
71
- ->label ('Approbation ' )
72
- ->placeholder ('N/A ' )
73
- ->date ()
74
- ->toggleable (),
75
- Tables \Columns \TextColumn::make ('declined_at ' )
76
- ->label ('Décliner ' )
77
- ->placeholder ('N/A ' )
78
- ->date ()
79
- ->toggleable (isToggledHiddenByDefault: true ),
72
+ BadgeableColumn::make ('status ' )
73
+ ->label ('Statut ' )
74
+ ->getStateUsing (function ($ record ) {
75
+ if ($ record ->approved_at ) {
76
+ return $ record ->approved_at ->format ('d/m/Y ' );
77
+ }
78
+
79
+ if ($ record ->declined_at ) {
80
+ return $ record ->declined_at ->format ('d/m/Y ' );
81
+ }
82
+
83
+ return 'depuis le ' .$ record ->submitted_at ->format ('d/m/Y ' );
84
+ })
85
+ ->prefixBadges (function ($ record ) {
86
+ if ($ record ->approved_at ) {
87
+ return [
88
+ Badge::make ('Approuvé ' )
89
+ ->color ('success ' ),
90
+ ];
91
+ }
92
+
93
+ if ($ record ->declined_at ) {
94
+ return [
95
+ Badge::make ('Décliné ' )
96
+ ->color ('danger ' ),
97
+ ];
98
+ }
99
+
100
+ return [Badge::make ('En attente ' )
101
+ ->color ('warning ' )];
102
+ })
103
+ ->searchable ()
104
+ ->sortable (),
80
105
])
81
106
->actions ([
82
107
ActionGroup::make ([
You can’t perform that action at this time.
0 commit comments