This commit is contained in:
baghizadizn 2025-11-28 06:56:24 +00:00
parent d9953a97cd
commit 5a0aab856b
3 changed files with 108 additions and 16 deletions

View File

@ -540,12 +540,29 @@ class UsersController extends Controller
$application->save();
$user_id = $application->user_id;
// Get the user instance
$user = User::find($user_id);
if (!$user) {
Session::flash('error', get_phrase('User not found'));
return redirect()->back();
}
// Update user role to instructor
User::where('id', $user_id)->update(['role' => 'instructor']);
$user->role = 'instructor';
$user->save();
// Update instructor status to 1 (active)
Instructors::where('user_id', $user_id)->update(['status' => 1]);
$instructor = Instructors::where('user_id', $user_id)->first();
if (!$instructor) {
// Handle case where instructor record doesn't exist
Session::flash('error', get_phrase('Instructor record not found'));
return redirect()->back();
}
$instructor->status = 1;
$instructor->save();
// Send approval notification email
$user->notify(new \App\Notifications\InstructorApprovalNotification($application));
DB::commit();
Session::flash('success', get_phrase('Application approved successfully'));
@ -558,6 +575,7 @@ class UsersController extends Controller
return redirect()->back();
}
public function instructor_application_delete($id)
{
Application::where('id', $id)->delete();

View File

@ -0,0 +1,62 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class InstructorApprovalNotification extends Notification
{
use Queueable;
protected $application;
public function __construct($application)
{
$this->application = $application;
}
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
$actionUrl = url('/instructor/dashboard');
return (new MailMessage)
->subject('Instructor Application Approved - GROWNESA')
->view('vendor.notifications.email', [
'actionUrl' => $actionUrl,
'actionText' => 'Access Instructor Dashboard',
'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
{
return [
//
];
}
}

View File

@ -66,6 +66,11 @@
font-size: 14px;
border-top: 1px solid #dddddd;
}
.email-content {
white-space: pre-line;
margin-bottom: 20px;
}
</style>
</head>
@ -75,35 +80,43 @@
@endphp
<div class="email-container">
<div class="email-header">
@php
$condition = ($current_route == 'register' || $current_route == 'verification.send' || $current_route == 'admin.admins.store' || $current_route == 'admin.instructor.store' || $current_route == 'admin.student.store' || isset($_GET['type']) && $_GET['type'] == 'registration');
@endphp
@if ($condition)
@if ($current_route == 'register' || $current_route == 'verification.send' || $current_route == 'admin.admins.store' || $current_route == 'admin.instructor.store' || $current_route == 'admin.student.store' || (isset($_GET['type']) && $_GET['type'] == 'registration'))
{{ get_phrase('Email Verification Required') }}
@elseif($current_route == 'password.email')
{{ get_phrase('Password Reset Required') }}
@else
{{ get_phrase('Instructor Application Approved') }}
@endif
</div>
<div class="email-body">
<p style="text-align: center;">
@if ($condition)
{{ get_phrase('Please click the button below to verify your email address.') }}
@if ($current_route == 'register' || $current_route == 'verification.send' || $current_route == 'admin.admins.store' || $current_route == 'admin.instructor.store' || $current_route == 'admin.student.store' || (isset($_GET['type']) && $_GET['type'] == 'registration'))
<p style="text-align: center;">{{ get_phrase('Please click the button below to verify your email address.') }}</p>
@elseif($current_route == 'password.email')
{{ get_phrase('Please click the button below to reset your password.') }}
<p style="text-align: center;">{{ get_phrase('Please click the button below to reset your password.') }}</p>
@else
<div class="email-content">
{{ $extraMessage ?? '' }}
</div>
@endif
</p>
@if(isset($actionUrl) && isset($actionText))
<div class="button-container">
<a href="{{ $actionUrl }}" class="button">
@if ($condition)
@if ($current_route == 'register' || $current_route == 'verification.send' || $current_route == 'admin.admins.store' || $current_route == 'admin.instructor.store' || $current_route == 'admin.student.store' || (isset($_GET['type']) && $_GET['type'] == 'registration'))
{{ get_phrase('Verify Email') }}
@elseif($current_route == 'password.email')
{{ get_phrase('Reset Password') }}
@else
{{ $actionText }}
@endif
</a>
</div>
@if (!empty($extraMessage))
@endif
@if (!empty($extraMessage) && ($current_route == 'register' || $current_route == 'verification.send' || $current_route == 'admin.admins.store' || $current_route == 'admin.instructor.store' || $current_route == 'admin.student.store' || (isset($_GET['type']) && $_GET['type'] == 'registration') || $current_route == 'password.email'))
<p>{{ $extraMessage }}</p>
@endif
<p style="text-align: center;">{{ get_phrase('If you did not request this, you can ignore this email.') }}</p>
<p style="text-align: center;">{{ get_phrase('Thank you!') }}</p>
</div>
@ -112,5 +125,4 @@
</div>
</div>
</body>
</html>