1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Modules\Admins\Notifications\Auth; |
4
|
|
|
|
5
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
6
|
|
|
use Illuminate\Notifications\Notification; |
7
|
|
|
use Illuminate\Support\Carbon; |
8
|
|
|
use Illuminate\Support\Facades\Config; |
9
|
|
|
use Illuminate\Support\Facades\Lang; |
10
|
|
|
use Illuminate\Support\Facades\URL; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @see \Illuminate\Auth\Notifications\VerifyEmail |
14
|
|
|
*/ |
15
|
|
|
class VerifyEmail extends Notification |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* The callback that should be used to create the verify email URL. |
19
|
|
|
* |
20
|
|
|
* @var \Closure|null |
21
|
|
|
*/ |
22
|
|
|
public static $createUrlCallback; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The callback that should be used to build the mail message. |
26
|
|
|
* |
27
|
|
|
* @var \Closure|null |
28
|
|
|
*/ |
29
|
|
|
public static $toMailCallback; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Get the notification's channels. |
33
|
|
|
* |
34
|
|
|
* @param mixed $notifiable |
35
|
|
|
* @return array|string |
36
|
|
|
*/ |
37
|
|
|
public function via($notifiable) |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
return ['mail']; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Build the mail representation of the notification. |
44
|
|
|
* |
45
|
|
|
* @param mixed $notifiable |
46
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
47
|
|
|
*/ |
48
|
|
|
public function toMail($notifiable) |
49
|
|
|
{ |
50
|
|
|
$verificationUrl = $this->verificationUrl($notifiable); |
51
|
|
|
|
52
|
|
|
if (static::$toMailCallback) { |
53
|
|
|
return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return $this->buildMailMessage($verificationUrl); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get the verify email notification mail message for the given URL. |
61
|
|
|
* |
62
|
|
|
* @param string $url |
63
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
64
|
|
|
*/ |
65
|
|
|
protected function buildMailMessage($url) |
66
|
|
|
{ |
67
|
|
|
return (new MailMessage) |
68
|
|
|
->subject(Lang::get('Verify Email Address')) |
|
|
|
|
69
|
|
|
->line(Lang::get('Please click the button below to verify your email address.')) |
70
|
|
|
->action(Lang::get('Verify Email Address'), $url) |
|
|
|
|
71
|
|
|
->line(Lang::get('If you did not create an account, no further action is required.')); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get the verification URL for the given notifiable. |
76
|
|
|
* |
77
|
|
|
* @param mixed $notifiable |
78
|
|
|
* @return string |
79
|
|
|
*/ |
80
|
|
|
protected function verificationUrl($notifiable) |
81
|
|
|
{ |
82
|
|
|
if (static::$createUrlCallback) { |
83
|
|
|
return call_user_func(static::$createUrlCallback, $notifiable); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return URL::temporarySignedRoute( |
87
|
|
|
'admin.verification.verify', |
88
|
|
|
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), |
89
|
|
|
[ |
90
|
|
|
'id' => $notifiable->getKey(), |
91
|
|
|
'hash' => sha1($notifiable->getEmailForVerification()), |
92
|
|
|
] |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Set a callback that should be used when creating the email verification URL. |
98
|
|
|
* |
99
|
|
|
* @param \Closure $callback |
100
|
|
|
* @return void |
101
|
|
|
*/ |
102
|
|
|
public static function createUrlUsing($callback) |
103
|
|
|
{ |
104
|
|
|
static::$createUrlCallback = $callback; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Set a callback that should be used when building the notification mail message. |
109
|
|
|
* |
110
|
|
|
* @param \Closure $callback |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
|
|
public static function toMailUsing($callback) |
114
|
|
|
{ |
115
|
|
|
static::$toMailCallback = $callback; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.