Passed
Push — master ( 1d6d9a...2a90e7 )
by Ron
02:47 queued 12s
created

NewTechTip   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

4 Methods

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