|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Modules\Sellers\Notifications\Auth; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
|
6
|
|
|
use Illuminate\Notifications\Notification; |
|
7
|
|
|
use Illuminate\Support\Facades\Lang; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @see \Illuminate\Auth\Notifications\ResetPassword |
|
11
|
|
|
*/ |
|
12
|
|
|
class ResetPassword extends Notification |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* The password reset token. |
|
16
|
|
|
* |
|
17
|
|
|
* @var string |
|
18
|
|
|
*/ |
|
19
|
|
|
public $token; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* The callback that should be used to create the reset password URL. |
|
23
|
|
|
* |
|
24
|
|
|
* @var (\Closure(mixed, string): string)|null |
|
|
|
|
|
|
25
|
|
|
*/ |
|
26
|
|
|
public static $createUrlCallback; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* The callback that should be used to build the mail message. |
|
30
|
|
|
* |
|
31
|
|
|
* @var (\Closure(mixed, string): \Illuminate\Notifications\Messages\MailMessage)|null |
|
|
|
|
|
|
32
|
|
|
*/ |
|
33
|
|
|
public static $toMailCallback; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Create a notification instance. |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $token |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
3 |
|
public function __construct($token) |
|
42
|
|
|
{ |
|
43
|
3 |
|
$this->token = $token; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Get the notification's channels. |
|
48
|
|
|
* |
|
49
|
|
|
* @param mixed $notifiable |
|
50
|
|
|
* @return array|string |
|
51
|
|
|
*/ |
|
52
|
3 |
|
public function via($notifiable) |
|
53
|
|
|
{ |
|
54
|
3 |
|
return ['mail']; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Build the mail representation of the notification. |
|
59
|
|
|
* |
|
60
|
|
|
* @param mixed $notifiable |
|
61
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
|
62
|
|
|
*/ |
|
63
|
|
|
public function toMail($notifiable) |
|
64
|
|
|
{ |
|
65
|
|
|
if (static::$toMailCallback) { |
|
66
|
|
|
return call_user_func(static::$toMailCallback, $notifiable, $this->token); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return $this->buildMailMessage($this->resetUrl($notifiable)); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get the reset password notification mail message for the given URL. |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $url |
|
76
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function buildMailMessage($url) |
|
79
|
|
|
{ |
|
80
|
|
|
return (new MailMessage) |
|
81
|
|
|
->subject(Lang::get('Reset Password Notification')) |
|
|
|
|
|
|
82
|
|
|
->line(Lang::get('You are receiving this email because we received a password reset request for your account.')) |
|
83
|
|
|
->action(Lang::get('Reset Password'), $url) |
|
|
|
|
|
|
84
|
|
|
->line(Lang::get('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.sellers.expire')])) |
|
85
|
|
|
->line(Lang::get('If you did not request a password reset, no further action is required.')); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Get the reset URL for the given notifiable. |
|
90
|
|
|
* |
|
91
|
|
|
* @param mixed $notifiable |
|
92
|
|
|
* @return string |
|
93
|
|
|
*/ |
|
94
|
|
|
protected function resetUrl($notifiable) |
|
95
|
|
|
{ |
|
96
|
|
|
if (static::$createUrlCallback) { |
|
97
|
|
|
return call_user_func(static::$createUrlCallback, $notifiable, $this->token); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
return url(route('seller.password.reset', [ |
|
101
|
|
|
'token' => $this->token, |
|
102
|
|
|
'email' => $notifiable->getEmailForPasswordReset(), |
|
103
|
|
|
], false)); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Set a callback that should be used when creating the reset password button URL. |
|
108
|
|
|
* |
|
109
|
|
|
* @param \Closure(mixed, string): string $callback |
|
110
|
|
|
* @return void |
|
111
|
|
|
*/ |
|
112
|
|
|
public static function createUrlUsing($callback) |
|
113
|
|
|
{ |
|
114
|
|
|
static::$createUrlCallback = $callback; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Set a callback that should be used when building the notification mail message. |
|
119
|
|
|
* |
|
120
|
|
|
* @param \Closure(mixed, string): \Illuminate\Notifications\Messages\MailMessage $callback |
|
121
|
|
|
* @return void |
|
122
|
|
|
*/ |
|
123
|
|
|
public static function toMailUsing($callback) |
|
124
|
|
|
{ |
|
125
|
|
|
static::$toMailCallback = $callback; |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|