whisper-money/app/Notifications/VerifyEmailNotification.php

41 lines
1.2 KiB
PHP

<?php
namespace App\Notifications;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
class VerifyEmailNotification extends VerifyEmail
{
public function toMail($notifiable): MailMessage
{
$verificationUrl = $this->verificationUrl($notifiable);
return (new MailMessage)
->subject(__('Verify Your Email - Whisper Money'))
->markdown('mail.verify-email', [
'userName' => $notifiable->name,
'verificationUrl' => $verificationUrl,
]);
}
/**
* Build a signed verification URL that does not require an authenticated session,
* so the link verifies the email even when opened in a logged-out browser.
*/
protected function verificationUrl($notifiable): string
{
return URL::temporarySignedRoute(
'verification.verify.public',
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
[
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
],
);
}
}