1 | <?php |
||||
2 | |||||
3 | namespace Sfneal\PostOffice\Notifications; |
||||
4 | |||||
5 | use Illuminate\Bus\Queueable; |
||||
6 | use Illuminate\Bus\Queueable as QueueableTrait; |
||||
7 | use Illuminate\Contracts\Queue\ShouldQueue; |
||||
8 | use Illuminate\Notifications\Messages\MailMessage; |
||||
9 | use Illuminate\Queue\InteractsWithQueue; |
||||
10 | use Illuminate\Queue\SerializesModels; |
||||
11 | use Illuminate\Support\Collection; |
||||
12 | use Sfneal\PostOffice\Mailables\Mailable; |
||||
13 | |||||
14 | abstract class Notification extends \Illuminate\Notifications\Notification implements ShouldQueue |
||||
15 | { |
||||
16 | use Queueable, InteractsWithQueue, QueueableTrait, SerializesModels; |
||||
0 ignored issues
–
show
introduced
by
![]() |
|||||
17 | |||||
18 | /** |
||||
19 | * @var array channels to send notification via |
||||
20 | */ |
||||
21 | private const VIA = ['mail']; |
||||
22 | |||||
23 | /** |
||||
24 | * @var array channels to send notification via |
||||
25 | */ |
||||
26 | public $via; |
||||
27 | |||||
28 | /** |
||||
29 | * Create a new notification instance. |
||||
30 | */ |
||||
31 | public function __construct() |
||||
32 | { |
||||
33 | $this->via = $this->via ?? ['mail']; |
||||
34 | $this->onQueue(config('post-office.queue')); |
||||
35 | $this->onConnection(config('post-office.driver')); |
||||
36 | } |
||||
37 | |||||
38 | /** |
||||
39 | * Get the notification's delivery channels. |
||||
40 | * |
||||
41 | * @param mixed $notifiable |
||||
42 | * @return array |
||||
43 | */ |
||||
44 | public function via($notifiable): array |
||||
0 ignored issues
–
show
The parameter
$notifiable is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
45 | { |
||||
46 | return $this->via; |
||||
47 | } |
||||
48 | |||||
49 | /** |
||||
50 | * Get the mail representation of the notification. |
||||
51 | * |
||||
52 | * @param mixed $notifiable |
||||
53 | * @return MailMessage|Mailable |
||||
54 | */ |
||||
55 | abstract public function toMail($notifiable); |
||||
56 | |||||
57 | /** |
||||
58 | * Get the array representation of the notification. |
||||
59 | * |
||||
60 | * @param mixed $notifiable |
||||
61 | * @return array |
||||
62 | */ |
||||
63 | abstract public function toArray($notifiable): array; |
||||
64 | |||||
65 | /** |
||||
66 | * Send the Notification using the `Illuminate\Support\Facades\Notification` facade. |
||||
67 | * |
||||
68 | * @param Collection|array|mixed $notifiables |
||||
69 | */ |
||||
70 | public function send($notifiables): void |
||||
71 | { |
||||
72 | \Illuminate\Support\Facades\Notification::send($notifiables, $this); |
||||
73 | } |
||||
74 | |||||
75 | /** |
||||
76 | * Send the Notification immediately using the `Illuminate\Support\Facades\Notification` facade. |
||||
77 | * |
||||
78 | * @param Collection|array|mixed $notifiables |
||||
79 | */ |
||||
80 | public function sendNow($notifiables): void |
||||
81 | { |
||||
82 | \Illuminate\Support\Facades\Notification::sendNow($notifiables, $this); |
||||
83 | } |
||||
84 | } |
||||
85 |