Passed
Push — dev5a ( 915c64...c2cba2 )
by Ron
07:58
created

NewTechTipCommentNotification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace App\Notifications;
4
5
use App\TechTips;
6
use Illuminate\Bus\Queueable;
7
use Illuminate\Contracts\Queue\ShouldQueue;
8
use Illuminate\Notifications\Messages\MailMessage;
9
use Illuminate\Notifications\Notification;
10
11
12
class NewTechTipCommentNotification extends Notification implements ShouldQueue
13
{
14
    use Queueable;
15
    protected $name, $tipID;
16
17
    /**
18
     * Create a new notification instance.
19
     *
20
     * @return void
21
     */
22 4
    public function __construct($name, $tipID)
23
    {
24 4
        $this->name = $name;
25 4
        $this->tipID = $tipID;
26 4
    }
27
28
    /**
29
     * Get the notification's delivery channels.
30
     *
31
     * @param  mixed  $notifiable
32
     * @return array
33
     */
34 4
    public function via($notifiable)
35
    {
36 4
        return ['database'];
37
    }
38
39
    /**
40
     * Get the mail representation of the notification.
41
     *
42
     * @param  mixed  $notifiable
43
     * @return \Illuminate\Notifications\Messages\MailMessage
44
     */
45
    public function toMail($notifiable)
46
    {
47
        return (new MailMessage)
48
                    ->line('The introduction to the notification.')
49
                    ->action('Notification Action', url('/'))
50
                    ->line('Thank you for using our application!');
51
    }
52
53
    /**
54
     * Get the array representation of the notification.
55
     *
56
     * @param  mixed  $notifiable
57
     * @return array
58
     */
59 4
    public function toArray($notifiable)
60
    {
61 4
        $subject = TechTips::find($this->tipID)->subject;
62
63
        return [
64 4
            'type'    => 'warning',
65 4
            'message' => $this->name.' commented on your Tech Tip',
66 4
            'link'    => url(route(
67 4
                'tips.details',
68
                [
69 4
                    'id' => $this->tipID,
70 4
                    'name' => urlencode($subject)
71
                ]
72
            ))
73
        ];
74
    }
75
}
76