-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathComplaintNotification.php
More file actions
88 lines (76 loc) · 2.42 KB
/
ComplaintNotification.php
File metadata and controls
88 lines (76 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace App\Notifications;
use Illuminate\Notifications\Messages\DatabaseMessage;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Lang;
/**
* A notification to be sent when the legal complaint form is being used.
*/
class ComplaintNotification extends Notification
{
public $offendingUrls;
public $reason;
public $name;
public $mailAddress;
/**
* Create a notification instance.
*
* @param string $offendingUrls
* @param string $reason
* @param string $name
* @param string $mailAddress
* @return void
*/
public function __construct($offendingUrls, $reason, $name=null, $mailAddress=null)
{
$this->offendingUrls = $offendingUrls;
$this->reason = $reason;
$this->name = $name;
$this->mailAddress = $mailAddress;
}
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['database', 'mail'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$name = $this->name;
$mailAddress = $this->mailAddress;
if (empty($name)) {
$name = 'None';
}
if (empty($mailAddress)) {
$mailAddress = 'None';
}
$mailFrom = config('app.complaint-mail-sender');
$mailSubject = config('app.name') . ': Report of Illegal Content';
return (new MailMessage)
->from($mailFrom)
->subject($mailSubject)
->line(Lang::get('A message via the wikibase.cloud form for reporting illegal content has been submitted.'))
->line(Lang::get('Reporter name: ') . $name)
->line(Lang::get('Reporter email address: ') . $mailAddress)
->line(Lang::get('Reason why the information in question is illegal content:'))
->line($this->reason)
->line(Lang::get('URL(s) for the content in question:'))
->line($this->offendingUrls)
->line('---');
}
public function toDatabase($notifiable) {
$mail = $this->toMail($notifiable);
return (new DatabaseMessage($mail->toArray()));
}
}