ResetYourPassword::via()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Anomaly\UsersModule\User\Notification;
2
3
use Anomaly\Streams\Platform\Notification\Message\MailMessage;
4
use Anomaly\UsersModule\User\Contract\UserInterface;
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Notifications\Notification;
8
9
/**
10
 * Class ResetYourPassword
11
 *
12
 * @link   http://pyrocms.com/
13
 * @author PyroCMS, Inc. <[email protected]>
14
 * @author Ryan Thompson <[email protected]>
15
 */
16
class ResetYourPassword extends Notification implements ShouldQueue
17
{
18
19
    use Queueable;
20
21
    /**
22
     * Redirect here after activating.
23
     *
24
     * @var string
25
     */
26
    public $redirect;
27
28
    /**
29
     * Create a new UserHasRegistered instance.
30
     *
31
     * @param $redirect
32
     */
33
    public function __construct($redirect = '/')
34
    {
35
        $this->redirect = $redirect;
36
    }
37
38
    /**
39
     * Get the notification's delivery channels.
40
     *
41
     * @param  UserInterface $notifiable
42
     * @return array
43
     */
44
    public function via(UserInterface $notifiable)
45
    {
46
        return ['mail'];
47
    }
48
49
    /**
50
     * Return the mail message.
51
     *
52
     * @param  UserInterface $notifiable
53
     * @return MailMessage
54
     */
55
    public function toMail(UserInterface $notifiable)
56
    {
57
        $data = $notifiable->toArray();
58
59
        return (new MailMessage())
60
            ->error()
61
            ->view('anomaly.module.users::notifications.reset_your_password')
62
            ->subject(trans('anomaly.module.users::notification.reset_your_password.subject', $data))
63
            ->greeting(trans('anomaly.module.users::notification.reset_your_password.greeting', $data))
64
            ->line(trans('anomaly.module.users::notification.reset_your_password.notice', $data))
65
            ->line(trans('anomaly.module.users::notification.reset_your_password.warning', $data))
66
            ->line(trans('anomaly.module.users::notification.reset_your_password.instructions', $data))
67
            ->action(
68
                trans('anomaly.module.users::notification.reset_your_password.button', $data),
69
                $notifiable->route('reset', ['redirect' => $this->redirect])
70
            );
71
    }
72
}
73