@@ -65,6 +65,7 @@ public static function table(Table $table): Table
6565 ->actions ([
6666 ActionGroup::make ([
6767 Action::make ('approved ' )
68+ ->visible (fn ($ record ) => $ record ->submitted_at && (! $ record ->declined_at && ! $ record ->approved_at ))
6869 ->label ('Approuver ' )
6970 ->icon ('heroicon-s-check ' )
7071 ->color ('success ' )
@@ -74,10 +75,10 @@ public static function table(Table $table): Table
7475 ->modalIcon ('heroicon-s-check ' )
7576 ->action (function ($ record ): void {
7677 $ record ->approved_at = now ();
77- $ record ->declined_at = null ;
7878 $ record ->save ();
7979 }),
8080 Action::make ('declined ' )
81+ ->visible (fn ($ record ) => $ record ->submitted_at && (! $ record ->declined_at && ! $ record ->approved_at ))
8182 ->label ('Décliner ' )
8283 ->icon ('heroicon-s-x-mark ' )
8384 ->color ('warning ' )
@@ -87,32 +88,32 @@ public static function table(Table $table): Table
8788 ->modalIcon ('heroicon-s-x-mark ' )
8889 ->action (function ($ record ): void {
8990 $ record ->declined_at = now ();
90- $ record ->approved_at = null ;
9191 $ record ->save ();
9292 }),
93- // DeclinedAction::make('declined'),
9493 Tables \Actions \DeleteAction::make ('delete ' ),
9594 ]),
9695
9796 ])
9897 ->bulkActions ([
9998 Tables \Actions \BulkActionGroup::make ([
10099 BulkAction::make ('approved ' )
100+ ->visible (fn (?Collection $ records ) => ! empty ($ records ) || $ records ?->contains(fn ($ record ) => $ record ->submitted_at ))
101101 ->label ('Approuver la sélection ' )
102102 ->icon ('heroicon-s-check ' )
103103 ->color ('success ' )
104- ->action (fn (Collection $ records ) => $ records ->each ->update (['approved_at ' => now (), ' declined_at ' => null ]))
104+ ->action (fn (Collection $ records ) => $ records ->each ->update (['approved_at ' => now ()]))
105105 ->deselectRecordsAfterCompletion ()
106106 ->requiresConfirmation ()
107107 ->modalIcon ('heroicon-s-check ' )
108108 ->modalHeading ('Approuver ' )
109109 ->modalSubheading ('Voulez-vous vraiment approuver ces articles ? ' )
110110 ->modalButton ('Confirmer ' ),
111111 BulkAction::make ('declined ' )
112+ ->visible (fn (?Collection $ records ) => ! empty ($ records ) || $ records ?->contains(fn ($ record ) => $ record ->submitted_at ))
112113 ->label ('Décliner la sélection ' )
113114 ->icon ('heroicon-s-x-mark ' )
114115 ->color ('warning ' )
115- ->action (fn (Collection $ records ) => $ records ->each ->update (['declined_at ' => now (), ' approved_at ' => null ]))
116+ ->action (fn (Collection $ records ) => $ records ->each ->update (['declined_at ' => now ()]))
116117 ->deselectRecordsAfterCompletion ()
117118 ->requiresConfirmation ()
118119 ->modalIcon ('heroicon-s-x-mark ' )
0 commit comments