-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTeamInvitation.php
More file actions
51 lines (43 loc) · 1.33 KB
/
TeamInvitation.php
File metadata and controls
51 lines (43 loc) · 1.33 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
<?php namespace GeneaLabs\LaravelGovernor\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use GeneaLabs\LaravelGovernor\TeamInvitation as Invitation;
class TeamInvitation extends Notification
{
use Queueable;
protected $invitation;
public function __construct(Invitation $invitation)
{
$this->invitation = $invitation;
}
public function via($notifiable) : array
{
return ['mail'];
}
public function toMail($notifiable) : MailMessage
{
$appUrl = config("app.url");
$ownerName = $this->invitation->ownedBy?->name ?? "A team admin";
$teamName = $this->invitation->team?->name ?? "the team";
$message = [
"You have been invited by {$ownerName}",
"to join team '{$teamName}' on {$appUrl}."
];
$route = route(
"genealabs.laravel-governor.invitations.update",
$this->invitation->token
);
return (new MailMessage)
->greeting("Hello!")
->line(implode(" ", $message))
->action('Accept Invitation', url($route));
}
public function toArray($notifiable) : array
{
return [
//
];
}
}