Files
ots/app/Notifications/InviteToTeam.php
T
Twyco 5113ea56fc
CI/CD / test_and_check_app (push) Failing after 57s
CI/CD / Publish immutable image (push) Skipped
invite team member
2026-09-19 04:56:36 +02:00

78 lines
1.9 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\TeamInvite;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class InviteToTeam extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct()
{
//
}
/**
* 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(TeamInvite $invite): MailMessage
{
$user = User::whereEmail($invite->invited_email)->first();
return (new MailMessage)
->subject('Team Invitation')
->greeting(
$user !== null
? sprintf('Hello %s,', $user->name)
: 'Hello',
)
->line(sprintf(
'%s invited you to the %s team.',
$invite->invitedBy->name,
$invite->team->name,
))
->linesIf($user === null, [
'It seems like you don\'t have an account yet.',
'Create one now for free to join the team.',
])
->action($user === null
? 'Register and join this team'
: 'Join this team',
route($user === null
? 'register'
: 'teams.invite.create',
['inviteToken' => $invite->plainInviteToken()]
));
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}