3
3
namespace App \Filament \Resources ;
4
4
5
5
use App \Filament \Resources \UserResource \Pages ;
6
- use App \Filament \Resources \UserResource \RelationManagers ;
7
6
use App \Models \User ;
7
+ use App \Settings \MailSettings ;
8
+ use Exception ;
9
+ use Filament \Facades \Filament ;
8
10
use Filament \Forms ;
11
+ use Filament \Forms \Components \Actions \Action ;
9
12
use Filament \Forms \Components \Select ;
10
13
use Filament \Forms \Components \SpatieMediaLibraryFileUpload ;
11
14
use Filament \Forms \Form ;
12
- use Filament \Forms \Get ;
15
+ use Filament \Notifications \Auth \VerifyEmail ;
16
+ use Filament \Notifications \Notification ;
13
17
use Filament \Resources \Resource ;
14
18
use Filament \Tables ;
15
19
use Filament \Tables \Columns \SpatieMediaLibraryImageColumn ;
16
20
use Filament \Tables \Table ;
17
21
use Illuminate \Contracts \Support \Htmlable ;
18
- use Illuminate \Database \Eloquent \Builder ;
19
22
use Illuminate \Database \Eloquent \Model ;
20
- use Illuminate \Database \Eloquent \SoftDeletingScope ;
21
- use Illuminate \Support \Facades \DB ;
22
23
use Illuminate \Support \Facades \Hash ;
23
24
use Illuminate \Support \Str ;
24
25
@@ -35,7 +36,6 @@ public static function form(Form $form): Form
35
36
{
36
37
return $ form
37
38
->schema ([
38
-
39
39
Forms \Components \Section::make ()
40
40
->schema ([
41
41
Forms \Components \Grid::make ()
@@ -97,12 +97,21 @@ public static function form(Form $form): Form
97
97
Forms \Components \Section::make ()
98
98
->schema ([
99
99
Forms \Components \Placeholder::make ('email_verified_at ' )
100
+ ->label (__ ('resource.general.email_verified_at ' ))
100
101
->content (fn (User $ record ): ?string => $ record ->email_verified_at ),
102
+ Forms \Components \Actions::make ([
103
+ Action::make ('resend_verification ' )
104
+ ->label (__ ('resource.user.actions.resend_verification ' ))
105
+ ->color ('secondary ' )
106
+ ->action (fn (MailSettings $ settings , Model $ record ) => static ::doResendEmailVerification ($ settings , $ record )),
107
+ ])
108
+ ->hidden (fn (User $ user ) => $ user ->email_verified_at != null )
109
+ ->fullWidth (),
101
110
Forms \Components \Placeholder::make ('created_at ' )
102
- ->label (' Created at ' )
111
+ ->label (__ ( ' resource.general.created_at ' ) )
103
112
->content (fn (User $ record ): ?string => $ record ->created_at ?->diffForHumans()),
104
113
Forms \Components \Placeholder::make ('updated_at ' )
105
- ->label (' Last modified at ' )
114
+ ->label (__ ( ' resource.general.updated_at ' ) )
106
115
->content (fn (User $ record ): ?string => $ record ->updated_at ?->diffForHumans()),
107
116
])
108
117
->hidden (fn (string $ operation ): bool => $ operation === 'create ' ),
@@ -191,4 +200,25 @@ public static function getNavigationGroup(): ?string
191
200
{
192
201
return __ ("menu.nav_group.access " );
193
202
}
203
+
204
+ public static function doResendEmailVerification ($ settings = null , $ user ): void
205
+ {
206
+ if (! method_exists ($ user , 'notify ' )) {
207
+ $ userClass = $ user ::class;
208
+
209
+ throw new Exception ("Model [ {$ userClass }] does not have a [notify()] method. " );
210
+ }
211
+
212
+ $ notification = new VerifyEmail ();
213
+ $ notification ->url = Filament::getVerifyEmailUrl ($ user );
214
+
215
+ $ settings ->loadMailSettingsToConfig ();
216
+
217
+ $ user ->notify ($ notification );
218
+
219
+ Notification::make ()
220
+ ->title (__ ('resource.user.notifications.notification_resent.title ' ))
221
+ ->success ()
222
+ ->send ();
223
+ }
194
224
}
0 commit comments