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