File tree Expand file tree Collapse file tree 1 file changed +26
-5
lines changed Expand file tree Collapse file tree 1 file changed +26
-5
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,11 +69,30 @@ 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 (),
72
+ BadgeableColumn::make ('status ' )
73
+ ->label ('Status ' )
74
+ ->getStateUsing (function ($ record ) {
75
+ if ($ record ->approved_at ) {
76
+ return [
77
+ 'label ' => 'Approuvé ' ,
78
+ 'date ' => $ record ->approved_at ->format ('d/m/Y H:i ' ),
79
+ ];
80
+ }
81
+ if ($ record ->declined_at ) {
82
+ return [
83
+ 'label ' => 'Décliné ' ,
84
+ 'date ' => $ record ->declined_at ->format ('d/m/Y H:i ' ),
85
+ ];
86
+ }
87
+ })
88
+ ->formatStateUsing (function ($ state ) {
89
+ if (is_array ($ state )) {
90
+ return "{$ state ['label ' ]} - {$ state ['date ' ]}" ;
91
+ }
92
+
93
+ return $ state ;
94
+ })
95
+ ->sortable (),
75
96
Tables \Columns \TextColumn::make ('declined_at ' )
76
97
->label ('Décliner ' )
77
98
->placeholder ('N/A ' )
You can’t perform that action at this time.
0 commit comments