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 NewFileUpload extends Notification implements ShouldQueue |
11
|
|
|
{ |
12
|
|
|
use Queueable; |
13
|
|
|
protected $details; |
14
|
|
|
|
15
|
|
|
// Constructor receives the file link details |
16
|
2 |
|
public function __construct($details) |
17
|
|
|
{ |
18
|
2 |
|
$this->details = $details; |
19
|
2 |
|
} |
20
|
|
|
|
21
|
|
|
// Notification is sent via email and dashboard notification |
22
|
2 |
|
public function via($notifiable) |
23
|
|
|
{ |
24
|
2 |
|
return ['mail', 'database']; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// Email notification |
28
|
|
|
public function toMail($notifiable) |
29
|
|
|
{ |
30
|
|
|
return (new MailMessage) |
31
|
|
|
->line('A new file has been uploaded to the file link - '.$this->details->link_name) |
32
|
|
|
->action('Click to View Link', |
33
|
|
|
url(route('links.details', |
34
|
|
|
[ |
35
|
|
|
'id' => $this->details->link_id, |
36
|
|
|
'name' => urlencode($this->details->link_name) |
37
|
|
|
]))); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
// Dashboard notification |
41
|
|
|
public function toArray($notifiable) |
42
|
|
|
{ |
43
|
|
|
return [ |
44
|
|
|
'type' => 'warning', |
45
|
|
|
'message' => 'New File(s) Uploaded to link - '.$this->details->link_name, |
46
|
|
|
'link' => url(route('links.details', |
47
|
|
|
[ |
48
|
|
|
'id' => $this->details->link_id, |
49
|
|
|
'name' => urlencode($this->details->link_name) |
50
|
|
|
])) |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|