65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications\Teams;
|
|
|
|
use App\Models\TeamInvitation as TeamInvitationModel;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class TeamInvitation extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*/
|
|
public function __construct(public TeamInvitationModel $invitation)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
/**
|
|
* Get the mail representation of the notification.
|
|
*/
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$team = $this->invitation->team;
|
|
$inviter = $this->invitation->inviter;
|
|
|
|
return (new MailMessage)
|
|
->subject(__("You've been invited to join :teamName", ['teamName' => $team->name]))
|
|
->line(__(':inviterName has invited you to join the :teamName team.', [
|
|
'inviterName' => $inviter->name,
|
|
'teamName' => $team->name,
|
|
]))
|
|
->action(__('Accept invitation'), url("/invitations/{$this->invitation->code}/accept"));
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'invitation_id' => $this->invitation->id,
|
|
'team_id' => $this->invitation->team_id,
|
|
'team_name' => $this->invitation->team->name,
|
|
'role' => $this->invitation->role->value,
|
|
];
|
|
}
|
|
}
|