Test Failed
Branch dev5 (4ce0ff)
by Ron
06:19
created

NewTechTipComment::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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