fix0716
This commit is contained in:
parent
6cfbe03314
commit
80cc7d7e03
|
|
@ -11,22 +11,13 @@ use Illuminate\Support\Facades\Log;
|
|||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function profilview(Request $request)
|
||||
{
|
||||
// Auth wi inna userge data gannawa
|
||||
$user = Auth::user();
|
||||
|
||||
// profile.blade.php file ekata data pass karanawa
|
||||
return view('profile', compact('user'));
|
||||
}
|
||||
public function profilview(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
return view('profile', compact('user'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Handle Student Registration (POST)
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
|
|
@ -47,8 +38,6 @@ public function profilview(Request $request)
|
|||
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
|
||||
return redirect('/')->with('success', 'Registration successful! Welcome to your dashboard.');
|
||||
}
|
||||
|
||||
|
|
@ -65,30 +54,24 @@ public function profilview(Request $request)
|
|||
|
||||
return redirect()->intended('/')->with('success', 'Welcome back!');
|
||||
}
|
||||
|
||||
return back()->withErrors([
|
||||
'email' => 'The provided credentials do not match our records.',
|
||||
])->onlyInput('email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Async Logout (POST Fetch)
|
||||
*/
|
||||
public function logout(Request $request) // FIX: Restored Request injection
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
try {
|
||||
if (Auth::check()) {
|
||||
Auth::logout();
|
||||
}
|
||||
|
||||
// Flush old fallback explicit keys
|
||||
$request->session()->forget(['user_id', 'user_name']);
|
||||
|
||||
if ($request->session()->isStarted()) {
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
}
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -102,26 +85,19 @@ public function profilview(Request $request)
|
|||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'first_name' => 'required|string|max:255',
|
||||
'last_name' => 'required|string|max:255',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
]);
|
||||
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
|
||||
$user->update([
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'phone' => $request->phone,
|
||||
]);
|
||||
|
||||
|
||||
return redirect()->back()->with('success', 'Profile updated successfully!');
|
||||
}
|
||||
{
|
||||
$request->validate([
|
||||
'first_name' => 'required|string|max:255',
|
||||
'last_name' => 'required|string|max:255',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
]);
|
||||
$user = Auth::user();
|
||||
$user->update([
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'phone' => $request->phone,
|
||||
]);
|
||||
return redirect()->back()->with('success', 'Profile updated successfully!');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,46 +4,39 @@ namespace App\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Feedback;
|
||||
use App\Models\user;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class FeedbackController extends Controller
|
||||
{
|
||||
// public function feedback(Request $request)
|
||||
// {
|
||||
// // 1. Validate incoming data
|
||||
// $validatedData = $request->validate([
|
||||
// 'feedback_type' => 'required',
|
||||
// 'subject' => 'required|string|max:255',
|
||||
// 'feedback_text' => 'required|string',
|
||||
// ]);
|
||||
|
||||
// // 2. Automatically inject the logged-in user's ID
|
||||
// $validatedData['user_id'] = auth()->id();
|
||||
// public function feedback(Request $request)
|
||||
// {
|
||||
|
||||
// $request->validate([
|
||||
// 'feedback_type' => 'required',
|
||||
// 'subject' => 'required|string|max:255',
|
||||
// 'feedback_text' => 'required|string',
|
||||
// ]);
|
||||
|
||||
// // 3. Save to database
|
||||
// Feedback::create($validatedData);
|
||||
|
||||
// $studentLogId = session('student_portal_log_id');
|
||||
|
||||
// return redirect()->back()->with('success', 'Feedback submitted successfully!');
|
||||
// }
|
||||
|
||||
// if (!$studentLogId) {
|
||||
// return redirect('/')->with('error', 'Please login first to submit feedback!');
|
||||
// }
|
||||
|
||||
public function feedback(Request $request)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'feedback_type' => 'required',
|
||||
'subject' => 'required|string|max:255',
|
||||
'feedback_text' => 'required|string',
|
||||
]);
|
||||
|
||||
|
||||
Feedback::create([
|
||||
'user_id' => auth()->id(),
|
||||
'feedback_type' => $request->feedback_type,
|
||||
'subject' => $request->subject,
|
||||
'feedback_text' => $request->feedback_text,
|
||||
'status' => 'Pending',
|
||||
]);
|
||||
|
||||
// DB::table('feedbacks')->insert([
|
||||
// 'student_id' => $studentLogId,
|
||||
// 'feedback_type' => $request->feedback_type,
|
||||
// 'subject' => $request->subject,
|
||||
// 'feedback_text' => $request->feedback_text,
|
||||
// 'status' => 'Pending',
|
||||
// 'created_at' => now(),
|
||||
// 'updated_at' => now(),
|
||||
// ]);
|
||||
|
||||
return redirect()->back()->with('success', 'Feedback submitted successfully!');
|
||||
}
|
||||
}
|
||||
|
||||
// return redirect()->back()->with('success', 'Feedback submitted successfully!');
|
||||
// }
|
||||
}
|
||||
|
|
@ -23,22 +23,39 @@ public function studentlogin(Request $request)
|
|||
->where('email', $request->username)
|
||||
->first();
|
||||
|
||||
|
||||
if ($student && Hash::check($request->password, $student->password) && $student->pin == $request->pin) {
|
||||
|
||||
|
||||
if ($student->status !== 'active' && $student->status !== '') {
|
||||
return redirect('/')->with('error', 'Your account is inactive!');
|
||||
}
|
||||
|
||||
|
||||
$request->session()->put('student_id', $student->studentid);
|
||||
|
||||
|
||||
return redirect()->route('student.portal')->with('success', 'Logged in successfully!');
|
||||
}
|
||||
|
||||
|
||||
return redirect('/')->with('error', 'Invalid Email, Password, or PIN!');
|
||||
}
|
||||
|
||||
|
||||
// public function showProfile(Request $request)
|
||||
// {
|
||||
|
||||
// $log_id = $request->session()->get('student_id');
|
||||
|
||||
|
||||
// if (!$log_id) {
|
||||
// return redirect('/')->with('error', 'Please login first!');
|
||||
// }
|
||||
|
||||
|
||||
// $student = DB::table('student_details')
|
||||
// ->where('student_portal_log_id', $log_id)
|
||||
// ->first();
|
||||
|
||||
|
||||
// if (!$student) {
|
||||
// return redirect()->back()->with('error', 'Student details not found!');
|
||||
// }
|
||||
|
||||
|
||||
// return view('StudentProfile', compact('student'));
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,8 @@ class studentportalnavController extends Controller
|
|||
public function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
|
||||
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Logged out successfully'
|
||||
|
|
|
|||
|
|
@ -2,8 +2,13 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\StudentPortalLog;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\studentDetails;
|
||||
|
||||
|
||||
class studentsController extends Controller
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||
|
||||
class Feedback extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'feedbacks';
|
||||
protected $table = 'feedback';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'feedback_type',
|
||||
'subject',
|
||||
'feedback_text',
|
||||
'student_id',
|
||||
'feedback_type',
|
||||
'subject',
|
||||
'feedback_text',
|
||||
'status'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('feedback', function (Blueprint $table) {
|
||||
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropColumn('user_id');
|
||||
$table->foreignId('student_id')->after('id')->constrained('student_portal_logs')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('student_id', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -150,35 +150,11 @@ body{
|
|||
<i class="fas fa-paper-plane"></i>Submit Feedback
|
||||
</button>
|
||||
</form>
|
||||
<!-- <form id="feedbackForm" action="{{ route('feedback.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label class="form-label"> Feedback Type </label>
|
||||
<select class="form-select" id="feedbackType" required>
|
||||
<option value=""> Select Type </option>
|
||||
<option value="Course">Course</option>
|
||||
<option value="Lecturer">Lecturer </option>
|
||||
<option value="Workshop">Workshop </option>
|
||||
<option value="Facilities"> Facilities </option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Subject </label>
|
||||
<input type="text" class="form-control" id="feedbackSubject" placeholder="Enter subject" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Your Feedback </label>
|
||||
<textarea class="form-control" id="feedbackText" rows="5" placeholder="Write your feedback" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="submit-btn">
|
||||
<i class="fas fa-paper-plane"></i>Submit Feedback
|
||||
</button>
|
||||
</form> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Complaint Form -->
|
||||
<div class="col-lg-6">
|
||||
<!-- <div class="col-lg-6">
|
||||
<div class="feedback-card">
|
||||
<h4 class="card-title"><i class="fas fa-exclamation-triangle"></i> Submit Complaint</h4>
|
||||
<form id="complaintForm">
|
||||
|
|
@ -206,8 +182,53 @@ body{
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<form id="feedbackForm" action="{{ route('feedback.store') }}" method="POST">
|
||||
@csrf
|
||||
|
||||
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul class="mb-0">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label"> Feedback Type </label>
|
||||
<select class="form-select" id="feedbackType" name="feedback_type" required>
|
||||
<option value=""> Select Type </option>
|
||||
<option value="Course" {{ old('feedback_type') == 'Course' ? 'selected' : '' }}>Course</option>
|
||||
<option value="Lecturer" {{ old('feedback_type') == 'Lecturer' ? 'selected' : '' }}>Lecturer</option>
|
||||
<option value="Workshop" {{ old('feedback_type') == 'Workshop' ? 'selected' : '' }}>Workshop</option>
|
||||
<option value="Facilities" {{ old('feedback_type') == 'Facilities' ? 'selected' : '' }}>Facilities</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Subject </label>
|
||||
<input type="text" class="form-control" id="feedbackSubject" name="subject" value="{{ old('subject') }}" placeholder="Enter subject" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Your Feedback </label>
|
||||
<textarea class="form-control" id="feedbackText" name="feedback_text" rows="5" placeholder="Write your feedback" required>{{ old('feedback_text') }}</textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="submit-btn">
|
||||
<i class="fas fa-paper-plane"></i> Submit Feedback
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- Previous History Table -->
|
||||
<div class="history-card">
|
||||
<div class="history-head">
|
||||
|
|
@ -245,62 +266,6 @@ body{
|
|||
|
||||
</div>
|
||||
|
||||
<!-- JavaScript to handle Submissions -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const tableBody = document.getElementById('historyTableBody');
|
||||
|
||||
// Ada dwaya lassanata ganna function ekak
|
||||
function getFormattedDate() {
|
||||
const options = { day: '2-digit', month: 'long', year: 'numeric' };
|
||||
return new Date().toLocaleDateString('en-GB', options);
|
||||
}
|
||||
|
||||
// 1. Feedback Form Submission
|
||||
document.getElementById('feedbackForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const subject = document.getElementById('feedbackSubject').value;
|
||||
const date = getFormattedDate();
|
||||
|
||||
// Table eke udatama row ekak add karanna (tr)
|
||||
const newRow = document.createElement('tr');
|
||||
newRow.innerHTML = `
|
||||
<td>Feedback</td>
|
||||
<td>${subject}</td>
|
||||
<td>${date}</td>
|
||||
<td><span class="badge-status pending"> Pending </span></td>
|
||||
`;
|
||||
|
||||
// Aluth data eka table eke udatama insert karanawa
|
||||
tableBody.insertBefore(newRow, tableBody.firstChild);
|
||||
|
||||
// Form eka reset karanawa
|
||||
this.reset();
|
||||
alert('Feedback submitted successfully!');
|
||||
});
|
||||
|
||||
// 2. Complaint Form Submission
|
||||
document.getElementById('complaintForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const title = document.getElementById('complaintTitle').value;
|
||||
const date = getFormattedDate();
|
||||
|
||||
const newRow = document.createElement('tr');
|
||||
newRow.innerHTML = `
|
||||
<td>Complaint</td>
|
||||
<td>${title}</td>
|
||||
<td>${date}</td>
|
||||
<td><span class="badge-status pending"> Pending </span></td>
|
||||
`;
|
||||
|
||||
tableBody.insertBefore(newRow, tableBody.firstChild);
|
||||
|
||||
this.reset();
|
||||
alert('Complaint submitted successfully!');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
@ -284,12 +284,17 @@ Student Services
|
|||
</div>
|
||||
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<a href="/StudentProfile" class="text-decoration-none"style="color:#5E244E">
|
||||
|
||||
<a href="/StudentProfile" class="text-decoration-none"style="color:#5E244E">
|
||||
|
||||
<div class="service-card">
|
||||
|
||||
<i class="fa-solid fa-user"></i>
|
||||
|
||||
|
||||
<!-- <a href="{{ route('StudentProfile') }}" class="text-decoration-none"style="color:#5E244E">
|
||||
<div class="service-card">
|
||||
<i class="fas fa-user"></i> Profile
|
||||
</a> -->
|
||||
<h5>Student Profile</h5>
|
||||
|
||||
<p>Update your personal information.</p>
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ body {
|
|||
height: 200px;
|
||||
width: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 14px;
|
||||
/* border-radius: 14px; */
|
||||
}
|
||||
|
||||
.course-card .card-body {
|
||||
|
|
|
|||
|
|
@ -245,11 +245,13 @@
|
|||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<main>
|
||||
@yield('content')
|
||||
</main>
|
||||
|
||||
<footer class="site-footer" role="contentinfo">
|
||||
<footer class="site-footer" role="contentinfo" >
|
||||
<div class="container">
|
||||
<div class="row g-4">
|
||||
<div class="col-md-4">
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@
|
|||
alert('Server side error occurred during logout.');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -119,10 +119,11 @@ body{
|
|||
|
||||
.course-card {
|
||||
border: 1px solid var(--card-border);
|
||||
border-radius: 20px;
|
||||
/* border-radius: 20px; */
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
/* background: #fff; */
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
|
||||
}
|
||||
|
||||
.course-card:hover {
|
||||
|
|
@ -139,7 +140,7 @@ body{
|
|||
height: 190px;
|
||||
width: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 14px;
|
||||
/* border-radius: 14px; */
|
||||
transition: 0.5s;
|
||||
}
|
||||
|
||||
|
|
@ -263,27 +264,27 @@ body{
|
|||
transition: all 1s ease-out;
|
||||
}
|
||||
|
||||
/* Fade Up effect */
|
||||
|
||||
.fade-up-init {
|
||||
transform: translateY(40px);
|
||||
}
|
||||
|
||||
/* Fade Left (Slide from Right) effect */
|
||||
|
||||
.fade-left-init {
|
||||
transform: translateX(50px);
|
||||
}
|
||||
|
||||
/* Fade Right (Slide from Left) effect */
|
||||
|
||||
.fade-right-init {
|
||||
transform: translateX(-50px);
|
||||
}
|
||||
|
||||
/* Zoom In effect */
|
||||
|
||||
.zoom-in-init {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
/* Animation එක active වූ පසු (JS මඟින් මේ class එක එකතු කරයි) */
|
||||
|
||||
.animate-on-scroll.animated {
|
||||
opacity: 1;
|
||||
transform: translateY(0) translateX(0) scale(1);
|
||||
|
|
@ -320,7 +321,9 @@ body{
|
|||
</section>
|
||||
|
||||
{{-- ===================== OUR COURSES ===================== --}}
|
||||
<section class="section py-5" aria-labelledby="courses-heading">
|
||||
<section class="section py-5" aria-labelledby="courses-heading" >
|
||||
<!-- style=" background: linear-gradient(rgba(177, 155, 185, 0.65),rgba(133, 118, 129, 0.65)),
|
||||
url('https://images.unsplash.com/photo-1517524206127-48bbd363f3d7?auto=format&fit=crop&w=1600&q=80');" -->
|
||||
<div class="container py-5">
|
||||
|
||||
<div class="text-center mb-5 animate-on-scroll fade-up-init">
|
||||
|
|
|
|||
Loading…
Reference in New Issue