TA/web_JMW/app/Notifications/VerifyEmailNotification.php

69 lines
1.8 KiB
PHP

<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\URL;
class VerifyEmailNotification extends Notification
{
use Queueable;
/**
* 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
{
$verificationUrl = $this->verificationUrl($notifiable);
return (new MailMessage)
->subject('Verifikasi Email Anda')
->greeting('Halo ' . $notifiable->name . ',')
->line('Terima kasih telah mendaftar di Marketplace Mobil Bekas!')
->line('Silakan klik tombol di bawah untuk memverifikasi email Anda:')
->action('Verifikasi Email', $verificationUrl)
->line('Jika Anda tidak melakukan registrasi, abaikan email ini.')
->salutation('Salam, Tim Marketplace Mobil Bekas');
}
/**
* Get the verification URL for the user.
*/
protected function verificationUrl($notifiable): string
{
return URL::temporarySignedRoute(
'verification.verify',
Carbon::now()->addMinutes(60),
[
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
]
);
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}