refactor code untuk notifikasi email

This commit is contained in:
baghizadizn 2025-11-28 15:48:52 +07:00
parent 5a0aab856b
commit 3ee08f0029
4 changed files with 101 additions and 27 deletions

View File

@ -23,7 +23,7 @@ class CustomEmailVerificationNotification extends Notification
$verificationUrl = $this->verificationUrl($notifiable); $verificationUrl = $this->verificationUrl($notifiable);
return (new MailMessage) return (new MailMessage)
->subject('Custom Email Verification Subject') ->subject(get_phrase('Custom Email Verification Subject'))
->action('Verify Email Address', $verificationUrl); ->action('Verify Email Address', $verificationUrl);
} }

View File

@ -21,7 +21,7 @@ class CustomResetPasswordNotification extends Notification
public function toMail($notifiable) public function toMail($notifiable)
{ {
return (new MailMessage) return (new MailMessage)
->subject('Custom Password Reset Subject') ->subject(get_phrase('Custom Password Reset Subject'))
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false))); ->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)));
} }
} }

View File

@ -25,34 +25,14 @@ class InstructorApprovalNotification extends Notification
public function toMail(object $notifiable): MailMessage public function toMail(object $notifiable): MailMessage
{ {
$actionUrl = url('/instructor/dashboard');
return (new MailMessage) return (new MailMessage)
->subject('Instructor Application Approved - GROWNESA') ->subject(get_phrase('Instructor Application Approved') . ' - ' . config('app.name'))
->view('vendor.notifications.email', [ ->view('vendor.notifications.instructor_approval', [
'actionUrl' => $actionUrl, 'user' => $notifiable,
'actionText' => 'Access Instructor Dashboard', 'application' => $this->application
'extraMessage' => $this->buildEmailContent($notifiable)
]); ]);
} }
protected function buildEmailContent($notifiable)
{
$content = "Congratulations " . $notifiable->name . "!\n\n";
$content .= "We are pleased to inform you that your instructor application has been approved.\n\n";
$content .= "Application ID: " . $this->application->id . "\n\n";
$content .= "You now have access to:\n";
$content .= "• Instructor Dashboard\n";
$content .= "• Course Creation Tools\n";
$content .= "• Bootcamp Creation Tools\n";
$content .= "• Blog Creation Tools\n";
$content .= "• Revenue Tracking and Analytics\n\n";
$content .= "If you have any questions, please contact our support team.\n\n";
$content .= "Thank you for joining our instructor community!";
return $content;
}
public function toArray(object $notifiable): array public function toArray(object $notifiable): array
{ {
return [ return [

View File

@ -0,0 +1,94 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ get_phrase('Instructor Application Approved') }}</title>
<style>
/* Copy the same styles from your email.blade.php */
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 0;
}
.email-container {
max-width: 600px;
margin: 0 auto;
background-color: #ffffff;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.email-header {
background-color: #ffffff;
color: #000;
text-align: center;
padding: 20px;
font-size: 24px;
font-weight: bold;
}
.email-body {
padding: 20px;
color: #333333;
font-size: 16px;
line-height: 1.6;
}
.email-body .button-container {
text-align: center;
margin: 20px 0;
}
.email-body a.button {
display: inline-block;
background-color: #2f57ef;
color: white;
padding: 12px 24px;
text-decoration: none;
border-radius: 5px;
font-size: 16px;
font-weight: bold;
}
.email-footer {
background-color: #f0f3ff;
color: #2f57ef;
text-align: center;
padding: 10px;
font-size: 14px;
border-top: 1px solid #dddddd;
}
</style>
</head>
<body>
<div class="email-container">
<div class="email-header">
{{ get_phrase('Instructor Application Approved') }}
</div>
<div class="email-body">
<p><strong>{{ get_phrase('Congratulations') }} {{ $user->name }}!</strong></p>
<p>{{ get_phrase('We are pleased to inform you that your instructor application has been approved.') }}</p>
<p><strong>{{ get_phrase('Application ID') }}:</strong> {{ $application->id }}</p>
<p>{{ get_phrase('You now have access to') }}:</p>
<ul>
<li>{{ get_phrase('Instructor Dashboard') }}</li>
<li>{{ get_phrase('Course Creation Tools') }}</li>
<li>{{ get_phrase('Bootcamp Creation Tools') }}</li>
<li>{{ get_phrase('Blog Creation Tools') }}</li>
<li>{{ get_phrase('Revenue Tracking and Analytics') }}</li>
</ul>
<div class="button-container">
<a href="{{ url('/instructor/dashboard') }}" class="button">
{{ get_phrase('Access Instructor Dashboard') }}
</a>
</div>
<p>{{ get_phrase('If you have any questions, please contact our support team.') }}</p>
<p>{{ get_phrase('Thank you for joining our instructor community!') }}</p>
</div>
<div class="email-footer">
<p>{{ config('app.name') }}</p>
</div>
</div>
</body>
</html>