Files
econom/app/Notifications/Teams/TeamInvitation.php
brusnitsyn fb2e6c58e3
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
first commit
2026-04-06 00:06:00 +09:00

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,
];
}
}