Issues (6)

src/Notifications/Notification.php (3 issues)

Severity
1
<?php
2
3
namespace CleaniqueCoders\LaravelHelper\Notifications;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Notifications\Messages\MailMessage;
7
use Illuminate\Notifications\Notification as BaseNotification;
8
9
class Notification extends BaseNotification
10
{
11
    use Queueable;
12
13
    public $subject;
14
15
    public $content;
16
17
    public $link;
18
19
    public $link_label;
20
21
    public $data;
22
23
    public $template;
24
25
    public $cc;
26
27
    public $bcc;
28
29
    public $attachments;
30
31
    /**
32
     * Create a new notification instance.
33
     */
34
    public function __construct(
35
        $subject,
36
        $content,
37
        $link = null,
38
        $link_label = null,
39
        $data = null,
40
        $attachments = null,
41
        $cc = null,
42
        $bcc = null,
43
        $template = 'mail.notification'
44
    ) {
45
        $this->subject = $subject;
46
        $this->content = $content;
47
        $this->link = $link;
48
        $this->link_label = $link_label;
49
        $this->data = $data;
50
        $this->template = $template;
51
        $this->cc = $cc;
52
        $this->bcc = $bcc;
53
        $this->attachments = $attachments;
54
    }
55
56
    /**
57
     * Get the notification's delivery channels.
58
     *
59
     * @param  mixed  $notifiable
60
     * @return array
61
     */
62
    public function via($notifiable)
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 ignore-unused  annotation

62
    public function via(/** @scrutinizer ignore-unused */ $notifiable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
63
    {
64
        return ['mail', 'database'];
65
    }
66
67
    /**
68
     * Get the mail representation of the notification.
69
     *
70
     * @param  mixed  $notifiable
71
     * @return \Illuminate\Notifications\Messages\MailMessage
72
     */
73
    public function toMail($notifiable)
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 ignore-unused  annotation

73
    public function toMail(/** @scrutinizer ignore-unused */ $notifiable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
74
    {
75
        $mail = (new MailMessage())
76
            ->subject($this->subject)
77
            ->markdown($this->template, [
78
                'subject' => $this->subject,
79
                'content' => $this->content,
80
                'link' => $this->link,
81
                'link_label' => $this->link_label,
82
                'data' => $this->data,
83
            ]);
84
85
        if ($this->cc) {
86
            $mail->cc($this->cc);
87
        }
88
89
        if ($this->bcc) {
90
            $mail->bcc($this->bcc);
91
        }
92
93
        if ($this->attachments) {
94
            if (is_array($this->attachments)) {
95
                foreach ($this->attachments as $attachment) {
96
                    $mail->attach($attachment);
97
                }
98
            } else {
99
                $mail->attach($this->attachments);
100
            }
101
        }
102
103
        return $mail;
104
    }
105
106
    /**
107
     * Get the array representation of the notification.
108
     *
109
     * @param  mixed  $notifiable
110
     * @return array
111
     */
112
    public function toArray($notifiable)
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 ignore-unused  annotation

112
    public function toArray(/** @scrutinizer ignore-unused */ $notifiable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
113
    {
114
        return [
115
            'subject' => $this->subject,
116
            'content' => $this->content,
117
            'link' => $this->link,
118
            'link_label' => $this->link_label,
119
            'data' => $this->data,
120
            'template' => $this->template,
121
            'cc' => $this->cc,
122
            'bcc' => $this->bcc,
123
            'attachments' => $this->attachments,
124
        ];
125
    }
126
}
127