|
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 ProjectIsAtEightyPercentTime extends Notification |
|
11
|
|
|
{ |
|
12
|
|
|
use Queueable; |
|
13
|
|
|
|
|
14
|
|
|
public $user; |
|
15
|
|
|
public $project; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Create a new notification instance. |
|
19
|
|
|
* |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct($user, $project) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->user = $user; |
|
25
|
|
|
$this->project = $project; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Get the notification's delivery channels. |
|
30
|
|
|
* |
|
31
|
|
|
* @param mixed $notifiable |
|
32
|
|
|
* @return array |
|
33
|
|
|
*/ |
|
34
|
|
|
public function via($notifiable) |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
// @todo OPT-IN ONLY FOR MAIL. |
|
37
|
|
|
return ['mail', 'database']; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Get the mail representation of the notification. |
|
42
|
|
|
* |
|
43
|
|
|
* @param mixed $notifiable |
|
44
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage |
|
45
|
|
|
*/ |
|
46
|
|
|
public function toMail($notifiable) |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
return (new MailMessage) |
|
49
|
|
|
->subject($this->project->title . ' is at 80% time utilized!') |
|
50
|
|
|
->line('Hey '. $this->user->name) |
|
51
|
|
|
->line('We just thought we\'d let you know that your project '.$this->project->title.' on Trackr is at 80% time utilised.') |
|
52
|
|
|
->action('Check Time Logs', route('projects.show', $this->project)) |
|
53
|
|
|
->line('Thanks for using Trackr!'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get the array representation of the notification. |
|
58
|
|
|
* |
|
59
|
|
|
* @param mixed $notifiable |
|
60
|
|
|
* @return array |
|
61
|
|
|
*/ |
|
62
|
|
|
public function toArray($notifiable) |
|
|
|
|
|
|
63
|
|
|
{ |
|
64
|
|
|
return [ |
|
65
|
|
|
'author' => 'Trackr Bot', |
|
66
|
|
|
'title' => $this->project->title . ' is at 80% time utilised!', |
|
67
|
|
|
'message' => $this->project->title.' is at 80% time utilised!', |
|
68
|
|
|
'link' => route('projects.show', $this->project) |
|
69
|
|
|
]; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.