1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Devpri\Tinre\Notifications; |
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
|
|
|
class EmailVerificationNotification extends Notification |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* The callback that should be used to build the mail message. |
16
|
|
|
* |
17
|
|
|
* @var \Closure|null |
18
|
|
|
*/ |
19
|
|
|
public static $toMailCallback; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Get the notification's channels. |
23
|
|
|
* |
24
|
|
|
* @param mixed $notifiable |
25
|
|
|
* @return array|string |
26
|
|
|
*/ |
27
|
2 |
|
public function via($notifiable) |
|
|
|
|
28
|
|
|
{ |
29
|
2 |
|
return ['mail']; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Build the mail representation of the notification. |
34
|
|
|
* |
35
|
|
|
* @param mixed $notifiable |
36
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
37
|
|
|
*/ |
38
|
2 |
|
public function toMail($notifiable) |
39
|
|
|
{ |
40
|
2 |
|
$verificationUrl = $this->verificationUrl($notifiable); |
41
|
|
|
|
42
|
2 |
|
if (static::$toMailCallback) { |
43
|
|
|
return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl); |
44
|
|
|
} |
45
|
|
|
|
46
|
2 |
|
return (new MailMessage) |
47
|
2 |
|
->subject(Lang::get('Verify Email Address')) |
48
|
2 |
|
->line(Lang::get('Please click the button below to verify your email address.')) |
49
|
2 |
|
->action(Lang::get('Verify Email Address'), $verificationUrl) |
50
|
2 |
|
->line(Lang::get('If you did not create an account, no further action is required.')); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get the verification URL for the given notifiable. |
55
|
|
|
* |
56
|
|
|
* @param mixed $notifiable |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
2 |
|
protected function verificationUrl($notifiable) |
60
|
|
|
{ |
61
|
2 |
|
return URL::temporarySignedRoute( |
62
|
2 |
|
'verification.verify', |
63
|
2 |
|
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), |
64
|
|
|
[ |
65
|
2 |
|
'id' => $notifiable->getKey(), |
66
|
2 |
|
'hash' => sha1($notifiable->getEmailForVerification()), |
67
|
|
|
] |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Set a callback that should be used when building the notification mail message. |
73
|
|
|
* |
74
|
|
|
* @param \Closure $callback |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
public static function toMailUsing($callback) |
78
|
|
|
{ |
79
|
|
|
static::$toMailCallback = $callback; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.