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 UserPendingActivation |
11
|
|
|
* |
12
|
|
|
* @link http://pyrocms.com/ |
13
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
14
|
|
|
* @author Ryan Thompson <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class UserPendingActivation extends Notification implements ShouldQueue |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
use Queueable; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The user pending activation. |
23
|
|
|
* |
24
|
|
|
* @var UserInterface |
25
|
|
|
*/ |
26
|
|
|
public $user; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Create a new UserPendingActivation instance. |
30
|
|
|
* |
31
|
|
|
* @param UserInterface $user |
32
|
|
|
*/ |
33
|
|
|
public function __construct(UserInterface $user) |
34
|
|
|
{ |
35
|
|
|
$this->user = $user; |
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
|
|
View Code Duplication |
public function toMail(UserInterface $notifiable) |
|
|
|
|
56
|
|
|
{ |
57
|
|
|
$data = $this->user->toArray(); |
58
|
|
|
|
59
|
|
|
return (new MailMessage()) |
60
|
|
|
->view('anomaly.module.users::notifications.user_pending_activation') |
61
|
|
|
->subject(trans('anomaly.module.users::notification.user_pending_activation.subject', $data)) |
62
|
|
|
->line(trans('anomaly.module.users::notification.user_pending_activation.instructions', $data)) |
63
|
|
|
->action( |
64
|
|
|
trans('anomaly.module.users::notification.user_pending_activation.button', $data), |
65
|
|
|
url('admin/users/edit/' . $this->user->getId()) |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.