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 77use App \Actions \Article \ApprovedArticleAction ;
88use App \Filament \Resources \ArticleResource \Pages ;
99use App \Models \Article ;
10+ use Awcodes \FilamentBadgeableColumn \Components \Badge ;
11+ use Awcodes \FilamentBadgeableColumn \Components \BadgeableColumn ;
1012use Filament \Resources \Resource ;
1113use Filament \Support \Enums \MaxWidth ;
1214use Filament \Tables ;
@@ -67,16 +69,39 @@ public static function table(Table $table): Table
6769 ->label ('Soumission ' )
6870 ->placeholder ('N/A ' )
6971 ->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 (),
80105 ])
81106 ->actions ([
82107 ActionGroup::make ([
You can’t perform that action at this time.
0 commit comments