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

UpdateTechTipNotification::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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