|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace MedianetDev\LaravelAuthApi\Http\Controllers\Traits\Notifications; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
|
6
|
|
|
use Illuminate\Notifications\Notification; |
|
7
|
|
|
use Illuminate\Support\Facades\Lang; |
|
8
|
|
|
|
|
9
|
|
|
class ResetPassword extends Notification |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* The password reset token. |
|
13
|
|
|
* |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
public $token; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* The callback that should be used to build the mail message. |
|
20
|
|
|
* |
|
21
|
|
|
* @var \Closure|null |
|
22
|
|
|
*/ |
|
23
|
|
|
public static $toMailCallback; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Create a notification instance. |
|
27
|
|
|
* |
|
28
|
|
|
* @param string $token |
|
29
|
|
|
* @return void |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct($token) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->token = $token; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Get the notification's channels. |
|
38
|
|
|
* |
|
39
|
|
|
* @param mixed $notifiable |
|
40
|
|
|
* @return array|string |
|
41
|
|
|
*/ |
|
42
|
|
|
public function via($notifiable) |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
return ['mail']; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Build the mail representation of the notification. |
|
49
|
|
|
* |
|
50
|
|
|
* @param mixed $notifiable |
|
51
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
|
52
|
|
|
*/ |
|
53
|
|
|
public function toMail($notifiable) |
|
54
|
|
|
{ |
|
55
|
|
|
if (static::$toMailCallback) { |
|
56
|
|
|
return call_user_func(static::$toMailCallback, $notifiable, $this->token); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return (new MailMessage) |
|
60
|
|
|
->subject(Lang::get('Reset Password Notification')) |
|
61
|
|
|
->line(Lang::get('You are receiving this email because we received a password reset request for your account.')) |
|
62
|
|
|
->action($this->token, '') |
|
63
|
|
|
->line(Lang::get('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')])) |
|
64
|
|
|
->line(Lang::get('If you did not request a password reset, no further action is required.')); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Set a callback that should be used when building the notification mail message. |
|
69
|
|
|
* |
|
70
|
|
|
* @param \Closure $callback |
|
71
|
|
|
* @return void |
|
72
|
|
|
*/ |
|
73
|
|
|
public static function toMailUsing($callback) |
|
74
|
|
|
{ |
|
75
|
|
|
static::$toMailCallback = $callback; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.