Passed
Push — dev5a ( c2cba2...4ce5a4 )
by Ron
07:44
created

UpdateTechTipNotification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 29.4%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 16
c 1
b 0
f 0
dl 0
loc 56
ccs 5
cts 17
cp 0.294
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 10 1
A via() 0 3 1
A toMail() 0 6 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\Notifications;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Notifications\Messages\MailMessage;
8
use Illuminate\Notifications\Notification;
9
10
class UpdateTechTipNotification extends Notification implements ShouldQueue
11
{
12
    use Queueable;
13
    protected $details;
14
15
    /**
16
     * Create a new notification instance.
17
     *
18
     * @return void
19
     */
20 4
    public function __construct($details)
21
    {
22 4
        $this->details = $details;
23 4
    }
24
25
    /**
26
     * Get the notification's delivery channels.
27
     *
28
     * @param  mixed  $notifiable
29
     * @return array
30
     */
31 4
    public function via($notifiable)
32
    {
33 4
        return ['mail', 'database'];
34
    }
35
36
    /**
37
     * Get the mail representation of the notification.
38
     *
39
     * @param  mixed  $notifiable
40
     * @return \Illuminate\Notifications\Messages\MailMessage
41
     */
42
    public function toMail($notifiable)
43
    {
44
        return (new MailMessage)
45
                    ->line('Tech Tip - '.$this->details->subject.' - has been updated')
46
                    ->line('Subject:  '.$this->details->subject)
47
                    ->action('Click to view Tech Tip', url(route('tips.details', ['id' => $this->details->tip_id, 'name' => urlencode($this->details->subject)])));
48
    }
49
50
    /**
51
     * Get the array representation of the notification.
52
     *
53
     * @param  mixed  $notifiable
54
     * @return array
55
     */
56
    public function toArray($notifiable)
57
    {
58
        return [
59
            'type'    => 'warning',
60
            'message' => 'Tech Tip Updated - '.$this->details->subject,
61
            'link'    => url(route(
62
                'tips.details',
63
                    [
64
                        'id' => $this->details->tip_id,
65
                        'name' => urlencode($this->details->subject)
66
                    ]
67
                ))
68
        ];
69
    }
70
}
71