lasthourcloud/app/Notifications/TransactionalEmails/InvitationLink.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2023-06-12 10:00:01 +00:00
<?php
namespace App\Notifications\TransactionalEmails;
use App\Models\Team;
use App\Models\TeamInvitation;
use App\Models\User;
use App\Notifications\Channels\TransactionalEmailChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
2023-07-28 08:55:26 +00:00
class InvitationLink extends Notification implements ShouldQueue
2023-06-12 10:00:01 +00:00
{
use Queueable;
2023-09-08 14:53:19 +00:00
public $tries = 5;
2024-06-10 20:43:34 +00:00
2023-08-10 19:00:02 +00:00
public function via(): array
2023-06-12 10:00:01 +00:00
{
return [TransactionalEmailChannel::class];
}
2024-07-25 20:04:05 +00:00
public function __construct(public User $user)
{
}
2024-06-10 20:43:34 +00:00
2023-09-01 13:52:18 +00:00
public function toMail(): MailMessage
{
$invitation = TeamInvitation::whereEmail($this->user->email)->first();
2023-06-12 10:00:01 +00:00
$invitation_team = Team::find($invitation->team->id);
2024-07-25 20:04:05 +00:00
$mail = new MailMessage();
$mail->subject('Last Hour: Invitation for ' . $invitation_team->name);
2023-06-12 10:00:01 +00:00
$mail->view('emails.invitation-link', [
'team' => $invitation_team->name,
2023-09-01 13:52:18 +00:00
'email' => $this->user->email,
2023-06-12 10:00:01 +00:00
'invitation_link' => $invitation->link,
]);
2024-06-10 20:43:34 +00:00
2023-06-12 10:00:01 +00:00
return $mail;
}
}