60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Auth\Notifications;
|
|
|
|
use App\Notifications\Concerns\BuildsMailMessage;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Modules\Auth\Entities\User;
|
|
|
|
class VerifyEmailNotification extends Notification
|
|
{
|
|
use BuildsMailMessage;
|
|
use Queueable;
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$expireMinutes = (int) config('auth.verification.expire_minutes', 60);
|
|
|
|
return $this->mailMessage(
|
|
subject: 'Pengesahan E-mel - MyKOPKB',
|
|
view: 'auth::emails.verify-email',
|
|
data: [
|
|
'name' => $notifiable->name,
|
|
'verificationUrl' => $this->verificationUrl($notifiable),
|
|
'expireMinutes' => $expireMinutes,
|
|
],
|
|
);
|
|
}
|
|
|
|
protected function verificationUrl(User $notifiable): string
|
|
{
|
|
$expireMinutes = (int) config('auth.verification.expire_minutes', 60);
|
|
$root = rtrim((string) config('app.url'), '/');
|
|
|
|
// Prefer APP_URL over the current request host so queued/local proxy
|
|
// contexts do not embed http://localhost in production emails.
|
|
URL::forceRootUrl($root);
|
|
if ($scheme = parse_url($root, PHP_URL_SCHEME)) {
|
|
URL::forceScheme($scheme);
|
|
}
|
|
|
|
return URL::temporarySignedRoute(
|
|
'verification.verify',
|
|
Carbon::now()->addMinutes($expireMinutes),
|
|
[
|
|
'id' => $notifiable->getKey(),
|
|
'hash' => sha1($notifiable->getEmailForVerification()),
|
|
]
|
|
);
|
|
}
|
|
}
|