Project Introduction

The Training Management System is a comprehensive software solution designed to streamline the planning, execution, and tracking of training programs within organizations. This system aims to enhance the learning experience for employees by providing a centralized platform for managing training schedules, resources, and participant progress. With the increasing importance of employee development and skill enhancement, the Training Management System addresses these needs by offering a user-friendly interface and robust functionalities for both trainers and trainees.

The platform features tools for course creation, registration management, attendance tracking, and performance evaluation. Users can easily browse available training programs, enroll in courses, and access learning materials. Additionally, the system includes reporting capabilities to assess training effectiveness and employee progress. By automating these processes, the Training Management System aims to improve organizational efficiency, foster a culture of continuous learning, and ensure that employees acquire the necessary skills to succeed in their roles.

Project Objectives

  • To develop an intuitive interface for users to manage and participate in training programs easily.
  • To implement course creation tools for trainers to design and organize training content.
  • To provide registration management features for tracking participant enrollment and attendance.
  • To enable performance evaluation tools to assess trainee progress and training effectiveness.
  • To facilitate communication between trainers and trainees through messaging and notifications.
  • To generate reports on training participation, completion rates, and feedback for continuous improvement.
  • To ensure data security and privacy for all user information and training records.
  • To enhance user engagement through features like reminders for upcoming training sessions and access to additional resources.

Project Modules

User Management Module

  • User Registration/Login: Allow users (administrators, trainers, and participants) to create accounts and log in securely.
  • Role Management: Differentiate between user roles (e.g., admin, trainer, trainee) with varying permissions and access levels.
  • Profile Management: Enable users to manage their profiles, including personal information, contact details, and training history.

Course Management Module

  • Course Creation: Allow administrators and trainers to create and manage training courses, including course descriptions, objectives, and prerequisites.
  • Content Management: Upload and organize training materials (e.g., documents, videos, presentations) associated with each course.
  • Course Scheduling: Schedule training sessions, including dates, times, locations, and trainers.

Participant Management Module

  • Enrollment Management: Allow participants to enroll in courses and manage their registrations.
  • Attendance Tracking: Track participant attendance for each training session and generate attendance reports.
  • Progress Tracking: Monitor participant progress throughout the training program, including completion of modules and assessments.

Assessment and Evaluation Module

  • Quiz and Test Creation: Create quizzes and assessments to evaluate participant knowledge and skills.
  • Grading and Feedback: Automatically grade assessments and provide feedback to participants.
  • Certification Management: Issue certificates of completion for participants who successfully finish training programs.

Reporting and Analytics Module

  • Performance Reports: Generate reports on participant performance, course completion rates, and assessment results.
  • Training Effectiveness: Analyze the effectiveness of training programs based on participant feedback and performance metrics.
  • Utilization Reports: Track resource utilization, including trainer availability and course attendance.

Feedback and Survey Module

  • Participant Feedback: Collect feedback from participants on training sessions, trainers, and course content.
  • Surveys: Conduct surveys to assess training needs and gather insights for future training initiatives.

Communication Module

  • Internal Messaging: Facilitate communication between trainers and participants through a secure messaging system.
  • Notifications and Reminders: Send automated notifications and reminders for upcoming training sessions, deadlines, and assessments.

Security and Access Control Module

  • Data Security: Ensure that sensitive user data and training information are stored securely.
  • Access Control: Manage access to different modules and features based on user roles.

Admin Dashboard Module

  • Dashboard Overview: Provide administrators with an overview of training activities, participant progress, and course statistics.
  • Management Tools: Allow admins to manage users, courses, and assessments from a centralized dashboard.

Resource Management Module

  • Resource Allocation: Manage resources required for training sessions, such as rooms, equipment, and materials.
  • Inventory Tracking: Track the availability and usage of training materials and resources.

Project Tables Queries


-- Create Users Table
CREATE TABLE Users (
UserId INT PRIMARY KEY IDENTITY(1,1),
Username NVARCHAR(50) NOT NULL UNIQUE,
PasswordHash NVARCHAR(256) NOT NULL,
Email NVARCHAR(100) NOT NULL UNIQUE,
FirstName NVARCHAR(50) NOT NULL,
LastName NVARCHAR(50) NOT NULL,
RoleId INT NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (RoleId) REFERENCES Roles(RoleId)
);
-- Create Roles Table
CREATE TABLE Roles (
RoleId INT PRIMARY KEY IDENTITY(1,1),
RoleName NVARCHAR(50) NOT NULL UNIQUE,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE()
);
-- Create Courses Table
CREATE TABLE Courses (
CourseId INT PRIMARY KEY IDENTITY(1,1),
CourseName NVARCHAR(100) NOT NULL,
Description NVARCHAR(MAX),
CreatedBy INT NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (CreatedBy) REFERENCES Users(UserId)
);
-- Create Content Table
CREATE TABLE Content (
ContentId INT PRIMARY KEY IDENTITY(1,1),
CourseId INT NOT NULL,
ContentType NVARCHAR(50) NOT NULL, -- e.g., Video, Document, Quiz
ContentLink NVARCHAR(255),
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (CourseId) REFERENCES Courses(CourseId)
);
-- Create Schedule Table
CREATE TABLE Schedules (
ScheduleId INT PRIMARY KEY IDENTITY(1,1),
CourseId INT NOT NULL,
StartDate DATETIME NOT NULL,
EndDate DATETIME NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (CourseId) REFERENCES Courses(CourseId)
);
-- Create Enrollment Table
CREATE TABLE Enrollments (
EnrollmentId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
CourseId INT NOT NULL,
EnrollmentDate DATETIME DEFAULT GETDATE(),
Status NVARCHAR(50) NOT NULL, -- e.g., Active, Completed, Dropped
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId),
FOREIGN KEY (CourseId) REFERENCES Courses(CourseId)
);
-- Create Attendance Table
CREATE TABLE Attendance (
AttendanceId INT PRIMARY KEY IDENTITY(1,1),
EnrollmentId INT NOT NULL,
AttendanceDate DATETIME NOT NULL,
Status NVARCHAR(20) NOT NULL, -- e.g., Present, Absent
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (EnrollmentId) REFERENCES Enrollments(EnrollmentId)
);
-- Create Assessments Table
CREATE TABLE Assessments (
AssessmentId INT PRIMARY KEY IDENTITY(1,1),
CourseId INT NOT NULL,
AssessmentType NVARCHAR(50) NOT NULL, -- e.g., Quiz, Exam
TotalMarks INT NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (CourseId) REFERENCES Courses(CourseId)
);
-- Create Feedback Table
CREATE TABLE Feedback (
FeedbackId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
CourseId INT NOT NULL,
FeedbackContent NVARCHAR(MAX) NOT NULL,
CreatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId),
FOREIGN KEY (CourseId) REFERENCES Courses(CourseId)
);
-- Create Notifications Table
CREATE TABLE Notifications (
NotificationId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
Message NVARCHAR(255) NOT NULL,
IsRead BIT NOT NULL DEFAULT 0,
CreatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);
-- Create Resources Table
CREATE TABLE Resources (
ResourceId INT PRIMARY KEY IDENTITY(1,1),
CourseId INT NOT NULL,
ResourceName NVARCHAR(100) NOT NULL,
ResourceLink NVARCHAR(255),
CreatedAt DATETIME DEFAULT GETDATE(),
UpdatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (CourseId) REFERENCES Courses(CourseId)
);
-- Create Reports Table
CREATE TABLE Reports (
ReportId INT PRIMARY KEY IDENTITY(1,1),
UserId INT NOT NULL,
ReportDate DATETIME NOT NULL,
ReportContent NVARCHAR(MAX),
CreatedAt DATETIME DEFAULT GETDATE(),
FOREIGN KEY (User Id) REFERENCES Users(UserId)
);

Explanation of Tables

Users: Stores user information, including their role in the system (e.g., Admin, Participant).

Roles: Defines different roles in the system (e.g., Admin, User).

Courses: Contains information about training courses, including name and description.

Content: Manages course content, specifying the type and link to the content.

Schedules: Tracks the schedule for each course, including start and end dates.

Enrollments: Records user enrollments in courses, including status and enrollment date.

Attendance: Manages attendance records for enrolled users in courses.

Assessments: Stores information about assessments related to courses, including type and total marks.

Feedback: Collects feedback from users regarding courses.

Notifications: Manages notifications sent to users, including read status.

Resources: Tracks additional resources related to courses, including links.

Reports: Stores reports generated by users, including content and date of the report.

To create the models and migrations for the provided SQL schema in Laravel 11, you can follow these steps.

Step 1: Create Migrations

You can create migrations using the Artisan command line tool. For each table, you will create a migration file. Here's how you can do it:


php artisan make:migration create_users_table
php artisan make:migration create_roles_table
php artisan make:migration create_courses_table
php artisan make:migration create_content_table
php artisan make:migration create_schedules_table
php artisan make:migration create_enrollments_table
php artisan make:migration create_attendance_table
php artisan make:migration create_assessments_table
php artisan make:migration create_feedback_table
php artisan make:migration create_notifications_table
php artisan make:migration create_resources_table
php artisan make:migration create_reports_table

Step 2: Define Migrations

Now, you can define the migrations in the generated files located in the database/migrations directory. Below are the migration definitions for each table:

1. Create Users Table Migration


use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id('User Id');
$table->string('Username', 50)->unique();
$table->string('PasswordHash', 256);
$table->string('Email', 100)->unique();
$table->string('FirstName', 50);
$table->string('LastName', 50);
$table->foreignId('RoleId')->constrained('roles');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('users');
}
}

2. Create Roles Table Migration


class CreateRolesTable extends Migration
{
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$table->id('RoleId');
$table->string('RoleName', 50)->unique();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('roles');
}
}

3. Create Courses Table Migration


class CreateCoursesTable extends Migration
{
public function up()
{
Schema::create('courses', function (Blueprint $table) {
$table->id('CourseId');
$table->string('CourseName', 100);
$table->text('Description')->nullable();
$table->foreignId('CreatedBy')->constrained('users');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('courses');
}
}

4. Create Content Table Migration


class CreateContentTable extends Migration
{
public function up()
{
Schema::create('content', function (Blueprint $table) {
$table->id('ContentId');
$table->foreignId('CourseId')->constrained('courses');
$table->string('ContentType', 50);
$table->string('ContentLink', 255)->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('content');
}
}

5. Create Schedules Table Migration


class CreateSchedulesTable extends Migration
{
public function up()
{
Schema::create('schedules', function (Blueprint $table) {
$table->id('ScheduleId');
$table->foreignId('CourseId')->constrained('courses');
$table->dateTime('StartDate');
$table->dateTime('EndDate');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('schedules');
}
}

6. Create Enrollments Table Migration


class CreateEnrollmentsTable extends Migration
{
public function up()
{
Schema::create('enrollments', function (Blueprint $table) {
$table->id('EnrollmentId');
$table->foreignId('User Id')->constrained('users');
$table->foreignId('CourseId')->constrained('courses');
$table->dateTime('EnrollmentDate')->default(now());
$table->string('Status', 50);
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('enrollments');
}
}

7. Create Attendance Table Migration


class CreateAttendanceTable extends Migration
{
public function up()
{
Schema::create('attendance', function (Blueprint $table) {
$table->id('AttendanceId');
$table->foreignId('EnrollmentId')->constrained('enrollments');
$table->dateTime('AttendanceDate');
$table->string('Status', 20);
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('attendance');
}
}

8. Create Assessments Table Migration


class CreateAssessmentsTable extends Migration
{
public function up()
{
Schema::create('assessments', function (Blueprint $table) {
$table->id('AssessmentId');
$table->foreignId('CourseId')->constrained('courses');
$table->string('AssessmentType', 50);
$table->integer('TotalMarks');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('assessments');
}
}

9. Create Feedback Table Migration


class CreateFeedbackTable extends Migration
{
public function up()
{
Schema::create('feedback', function (Blueprint $table) {
$table->id('FeedbackId');
$table->foreignId('User Id')->constrained('users');
$table->foreignId('CourseId')->constrained('courses');
$table->text('FeedbackContent');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('feedback');
}
}

10. Create Notifications Table Migration


class CreateNotificationsTable extends Migration
{
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->id('NotificationId');
$table->foreignId('User Id')->constrained('users');
$table->string('Message', 255);
$table->boolean('IsRead')->default(false);
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('notifications');
}
}

11. Create Resources Table Migration


class CreateResourcesTable extends Migration
{
public function up()
{
Schema::create('resources', function (Blueprint $table) {
$table->id('ResourceId');
$table->foreignId('CourseId')->constrained('courses');
$table->string('ResourceName', 100);
$table->string('ResourceLink', 255)->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('resources');
}
}

12. Create Reports Table Migration


class CreateReportsTable extends Migration
{
public function up()
{
Schema::create('reports', function (Blueprint $table) {
$table->id('ReportId');
$table->foreignId('User Id')->constrained('users');
$table->dateTime('ReportDate');
$table->text('ReportContent');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('reports');
}
}

Step 3: Create Eloquent Models

For each table, you will also create a corresponding Eloquent model. You can create models using the following commands:


php artisan make:model User
php artisan make:model Role
php artisan make:model Course
php artisan make:model Content
php artisan make:model Schedule
php artisan make:model Enrollment
php artisan make:model Attendance
php artisan make:model Assessment
php artisan make:model Feedback
php artisan make:model Notification
php artisan make:model Resource
php artisan make:model Report

Step 4: Define Eloquent Models

Below are the basic definitions for each model:

1. User Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use HasFactory;
protected $table = 'users';
public function roles()
{
return $this->belongsTo(Role::class, 'RoleId');
}
public function courses()
{
return $this->hasMany(Course::class, 'CreatedBy');
}
public function enrollments()
{
return $this->hasMany(Enrollment::class);
}
public function feedbacks()
{
return $this->hasMany(Feedback::class);
}
public function notifications()
{
return $this->hasMany(Notification::class);
}
public function reports()
{
return $this->hasMany(Report::class);
}
}

2. Role Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
use HasFactory;
protected $table = 'roles';
public function users()
{
return $this->hasMany(User::class, 'RoleId');
}
}

3. Course Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Course extends Model
{
use HasFactory;
protected $table = 'courses';
public function content()
{
return $this->hasMany(Content::class);
}
public function schedules()
{
return $this->hasMany(Schedule::class);
}
public function enrollments()
{
return $this->hasMany(Enrollment::class);
}
public function assessments()
{
return $this->hasMany(Assessment::class);
}
public function feedbacks()
{
return $this->hasMany(Feedback::class);
}
public function resources()
{
return $this->hasMany(Resource::class);
}
}

4. Content Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Content extends Model
{
use HasFactory;
protected $table = 'content';
public function course()
{
return $this->belongsTo(Course::class);
}
}

5. Schedule Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Schedule extends Model
{
use HasFactory;
protected $table = 'schedules';
public function course()
{
return $this->belongsTo(Course::class);
}
}

6. Enrollment Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Enrollment extends Model
{
use HasFactory;
protected $table = 'enrollments';
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
public function course()
{
return $this->belongsTo(Course::class);
}
public function attendance()
{
return $this->hasMany(Attendance::class);
}
}

7. Attendance Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Attendance extends Model
{
use HasFactory;
protected $table = 'attendance';
public function enrollment()
{
return $this->belongsTo(Enrollment::class);
}
}

8. Assessment Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Assessment extends Model
{
use HasFactory;
protected $table = 'assessments';
public function course()
{
return $this->belongsTo(Course::class);
}
}

9. Feedback Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Feedback extends Model
{
use HasFactory;
protected $table = 'feedback';
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
public function course()
{
return $this->belongsTo(Course::class);
}
}

10. Notification Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Notification extends Model
{
use HasFactory;
protected $table = 'notifications';
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}

11. Resource Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Resource extends Model
{
use HasFactory;
protected $table = 'resources';
public function course()
{
return $this->belongsTo(Course::class);
}
}

12. Report Model


namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Report extends Model
{
use HasFactory;
protected $table = 'reports';
public function user()
{
return $this->belongsTo(User::class, 'User Id');
}
}

Step 5: Run Migrations

After defining the migrations and models, you can run the migrations to create the tables in your database:


php artisan migrate

This will set up your database schema according to the defined migrations, and you will have the necessary models to interact with the database in your Laravel application.

To create controllers for each model with complete CRUD operations in Laravel, you can use the Artisan command line tool to generate the controllers.

Each controller will handle the basic CRUD operations: Create, Read, Update, and Delete.

Step 1: Create Controllers

You can create a controller for each model using the following commands:


php artisan make:controller UserController --resource
php artisan make:controller RoleController --resource
php artisan make:controller CourseController --resource
php artisan make:controller ContentController --resource
php artisan make:controller ScheduleController --resource
php artisan make:controller EnrollmentController --resource
php artisan make:controller AttendanceController --resource
php artisan make:controller AssessmentController --resource
php artisan make:controller FeedbackController --resource
php artisan make:controller NotificationController --resource
php artisan make:controller ResourceController --resource
php artisan make:controller ReportController --resource

The --resource flag generates a controller with methods for handling resourceful routes.

Step 2: Define CRUD Operations in Controllers

Below are examples of how to implement the CRUD operations in each controller. For brevity, I will provide a template for one controller, and you can replicate the structure for the others.

Example: UserController


namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function index()
{
$users = User::all();
return view('users.index', compact('users'));
}
public function create()
{
return view('users.create');
}
public function store(Request $request)
{
$request->validate([
'Username' => 'required|unique:users|max:50',
'PasswordHash' => 'required',
'Email' => 'required|email|unique:users|max:100',
'FirstName' => 'required|max:50',
'LastName' => 'required|max:50',
'RoleId' => 'required|exists:roles,RoleId',
]);
User::create($request->all());
return redirect()->route('users.index')->with('success', 'User created successfully.');
}
public function show(User $user)
{
return view('users.show', compact('user'));
}
public function edit(User $user)
{
return view('users.edit', compact('user'));
}
public function update(Request $request, User $user)
{
$request->validate([
'Username' => 'required|max:50|unique:users,Username,' . $user->id,
'Email' => 'required|email|max:100|unique:users,Email,' . $user->id,
'FirstName' => 'required|max:50',
'LastName' => 'required|max:50',
'RoleId' => 'required|exists:roles,RoleId',
]);
$user->update($request->all());
return redirect()->route('users.index')->with('success', 'User updated successfully.');
}
public function destroy(User $user)
{
$user->delete();
return redirect()->route('users.index')->with('success', 'User deleted successfully.');
}
}

Step 3: Create Views
You will need to create views for each of the CRUD operations. Here’s a basic structure for the views:
Index View (resources/views/users/index.blade.php)

@extends('layouts.app')
@section('content')
<h1>Users</h1>
<a href="{{ route('users.create') }}">Create User</a>
<table>
<thead>
<tr>
<th>Username</th>
<th>Email</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->Username }}</td>
<td>{{ $user->Email }}</td>
<td>
<a href="{{ route('users.show', $user) }}">View</a>
<a href="{{ route('users.edit', $user) }}">Edit</a>
<form action="{{ route('users.destroy', $user) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
@endsection

Create View (resources/views/users/create.blade.php)


@extends('layouts.app')
@section('content')
<h1>Create User</h1>
<form action="{{ route('users.store') }}" method="POST">
@csrf
<label for="Username">Username:</label>
<input type="text" name="Username" required>
<label for="PasswordHash">Password:</label>
<input type="password" name="PasswordHash" required>
<label for="Email">Email:</label>
<input type="email" name="Email" required>
<label for="FirstName">First Name:</label>
<input type="text" name="FirstName" required>
<label for="LastName">Last Name:</label>
<input type="text" name="LastName" required>
<label for="RoleId">Role:</label>
<select name="RoleId" required>
@foreach ($roles as $role)
<option value="{{ $role->RoleId }}">{{ $role->RoleName }}</option>
@endforeach
</select>
<button type="submit">Create</button>
</form>
@endsection

Edit View (resources/views/users/edit.blade.php)


@extends('layouts.app')
@section('content')
<h1>Edit User</h1>
<form action="{{ route('users.update', $user) }}" method="POST">
@csrf
@method('PUT')
<label for="Username">Username:</label>
<input type="text" name="Username" value="{{ $user->Username }}" required>
<label for="PasswordHash">Password:</label>
<input type="password" name="PasswordHash">
<label for="Email">Email:</label>
<input type="email" name="Email" value="{{ $user->Email }}" required>
<label for="FirstName">First Name:</label>
<input type="text" name="FirstName" value="{{ $user->FirstName }}" required>
<label for="LastName">Last Name:</label>
<input type="text" name="LastName" value="{{ $user->LastName }}" required>
<label for="RoleId">Role:</label>
<select name="RoleId" required>
@foreach ($roles as $role)
<option value="{{ $role->RoleId }}" {{ $role->RoleId == $user->RoleId ? 'selected' : '' }}>{{ $role->RoleName }}</option>
@endforeach
</select>
<button type="submit">Update</button>
</form>
@endsection

Show View (resources/views/users/show.blade.php)


@extends('layouts.app')
@section('content')
<h1>User Details</h1>
<p>Username: {{ $user->Username }}</p>
<p>Email: {{ $user->Email }}</p>
<p>First Name: {{ $user->FirstName }}</p>
<p>Last Name: {{ $user->LastName }}</p>
<p>Role: {{ $user->roles->RoleName }}</p>
<a href="{{ route('users.edit', $user) }}">Edit</a>
<form action="{{ route('users.destroy', $user) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit">Delete</button>
</form>
<a href="{{ route('users.index') }}">Back to Users</a>
@endsection

Step 4: Define Routes

You need to define the routes for the resource controllers in your routes/web.php file:


use App\Http\Controllers\UserController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\CourseController;
use App\Http\Controllers\ContentController;
use App\Http\Controllers\ScheduleController;
use App\Http\Controllers\EnrollmentController;
use App\Http\Controllers\AttendanceController;
use App\Http\Controllers\AssessmentController;
use App\Http\Controllers\FeedbackController;
use App\Http\Controllers\NotificationController;
use App\Http\Controllers\ResourceController;
use App\Http\Controllers\ReportController;
Route::resource('users', UserController::class);
Route::resource('roles', RoleController::class);
Route::resource('courses', CourseController::class);
Route::resource('content', ContentController::class);
Route::resource('schedules', ScheduleController::class);
Route::resource('enrollments', EnrollmentController::class);
Route::resource('attendance', AttendanceController::class);
Route::resource('assessments', AssessmentController::class);
Route::resource('feedback', FeedbackController::class);
Route::resource('notifications', NotificationController::class);
Route::resource('resources', ResourceController::class);
Route::resource('reports', ReportController::class);

Step 5: Repeat for Other Controllers

You can replicate the structure of the User Controller for the other controllers (e.g., RoleController, CourseController, etc.) by following the same pattern for CRUD operations and views.

This setup will provide a complete CRUD interface for each model in your Laravel application, allowing you to manage users, roles, courses, and other entities effectively.

Below are the remaining controllers for the models you specified, each with complete CRUD operations.

1. RoleController


namespace App\Http\Controllers;
use App\Models\Role;
use Illuminate\Http\Request;
class RoleController extends Controller
{
public function index()
{
$roles = Role::all();
return view('roles.index', compact('roles'));
}
public function create()
{
return view('roles.create');
}
public function store(Request $request)
{
$request->validate([
'RoleName' => 'required|unique:roles|max:50',
]);
Role::create($request->all());
return redirect()->route('roles.index')->with('success', 'Role created successfully.');
}
public function show(Role $role)
{
return view('roles.show', compact('role'));
}
public function edit(Role $role)
{
return view('roles.edit', compact('role'));
}
public function update(Request $request, Role $role)
{
$request->validate([
'RoleName' => 'required|max:50|unique:roles,RoleName,' . $role->RoleId,
]);
$role->update($request->all());
return redirect()->route('roles.index')->with('success', 'Role updated successfully.');
}
public function destroy(Role $role)
{
$role->delete();
return redirect()->route('roles.index')->with('success', 'Role deleted successfully.');
}
}

2. CourseController


namespace App\Http\Controllers;
use App\Models\Course;
use App\Models\User;
use Illuminate\Http\Request;
class CourseController extends Controller
{
public function index()
{
$courses = Course::all();
return view('courses.index', compact('courses'));
}
public function create()
{
$users = User::all();
return view('courses.create', compact('users'));
}
public function store(Request $request)
{
$request->validate([
'CourseName' => 'required|max:100',
'Description' => 'nullable',
'CreatedBy' => 'required|exists:users,User Id',
]);
Course::create($request->all());
return redirect()->route('courses.index')->with('success', 'Course created successfully.');
}
public function show(Course $course)
{
return view('courses.show', compact('course'));
}
public function edit(Course $course)
{
$users = User::all();
return view('courses.edit', compact('course', 'users'));
}
public function update(Request $request, Course $course)
{
$request->validate([
'CourseName' => 'required|max:100',
'Description' => 'nullable',
'CreatedBy' => 'required|exists:users,User Id',
]);
$course->update($request->all());
return redirect()->route('courses.index')->with('success', 'Course updated successfully.');
}
public function destroy(Course $course)
{
$course->delete();
return redirect()->route('courses.index')->with('success', 'Course deleted successfully.');
}
}

3. ContentController


namespace App\Http\Controllers;
use App\Models\Content;
use App\Models\Course;
use Illuminate\Http\Request;
class ContentController extends Controller
{
public function index()
{
$contents = Content::all();
return view('content.index', compact('contents'));
}
public function create()
{
$courses = Course::all();
return view('content.create', compact('courses'));
}
public function store(Request $request)
{
$request->validate([
'CourseId' => 'required|exists:courses,CourseId',
'ContentType' => 'required|max:50',
'ContentLink' => 'nullable|max:255',
]);
Content::create($request->all());
return redirect()->route('content.index')->with('success', 'Content created successfully.');
}
public function show(Content $content)
{
return view('content.show', compact('content'));
}
public function edit(Content $content)
{
$courses = Course::all();
return view('content.edit', compact('content', 'courses'));
}
public function update(Request $request, Content $content)
{
$request->validate([
'CourseId' => 'required|exists:courses,CourseId',
'ContentType' => 'required|max:50',
'ContentLink' => 'nullable|max:255',
]);
$content->update($request->all());
return redirect()->route('content.index')->with('success', 'Content updated successfully.');
}
public function destroy(Content $content)
{
$content->delete();
return redirect()->route('content.index')->with('success', 'Content deleted successfully.');
}
}

4. ScheduleController


namespace App\Http\Controllers;
use App\Models\Schedule;
use App\Models\Course;
use Illuminate\Http\Request;
class ScheduleController extends Controller
{
public function index()
{
$schedules = Schedule::all();
return view('schedules.index', compact('schedules'));
}
public function create()
{
$courses = Course::all();
return view('schedules.create', compact('courses'));
}
public function store(Request $request)
{
$request->validate([
'CourseId' => 'required|exists:courses,CourseId',
'StartDate' => 'required|date',
'EndDate' => 'required|date|after_or_equal:StartDate',
]);
Schedule::create($request->all());
return redirect()->route('schedules.index')->with('success', 'Schedule created successfully.');
}
public function show(Schedule $schedule)
{
return view('schedules.show', compact('schedule'));
}
public function edit(Schedule $schedule)
{
$courses = Course::all();
return view('schedules.edit', compact('schedule', 'courses'));
}
public function update(Request $request, Schedule $schedule)
{
$request->validate([
'CourseId' => 'required|exists:courses,CourseId',
'StartDate' => 'required|date',
'EndDate' => 'required|date|after_or_equal:StartDate',
]);
$schedule->update($request->all());
return redirect()->route('schedules.index')->with(' success', 'Schedule updated successfully.');
}
public function destroy(Schedule $schedule)
{
$schedule->delete();
return redirect()->route('schedules.index')->with('success', 'Schedule deleted successfully.');
}
}

5. EnrollmentController


namespace App\Http\Controllers;
use App\Models\Enrollment;
use App\Models\User;
use App\Models\Course;
use Illuminate\Http\Request;
class EnrollmentController extends Controller
{
public function index()
{
$enrollments = Enrollment::all();
return view('enrollments.index', compact('enrollments'));
}
public function create()
{
$users = User::all();
$courses = Course::all();
return view('enrollments.create', compact('users', 'courses'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'CourseId' => 'required|exists:courses,CourseId',
]);
Enrollment::create($request->all());
return redirect()->route('enrollments.index')->with('success', 'Enrollment created successfully.');
}
public function show(Enrollment $enrollment)
{
return view('enrollments.show', compact('enrollment'));
}
public function edit(Enrollment $enrollment)
{
$users = User::all();
$courses = Course::all();
return view('enrollments.edit', compact('enrollment', 'users', 'courses'));
}
public function update(Request $request, Enrollment $enrollment)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'CourseId' => 'required|exists:courses,CourseId',
]);
$enrollment->update($request->all());
return redirect()->route('enrollments.index')->with('success', 'Enrollment updated successfully.');
}
public function destroy(Enrollment $enrollment)
{
$enrollment->delete();
return redirect()->route('enrollments.index')->with('success', 'Enrollment deleted successfully.');
}
}

6. AttendanceController


namespace App\Http\Controllers;
use App\Models\Attendance;
use App\Models\User;
use App\Models\Course;
use Illuminate\Http\Request;
class AttendanceController extends Controller
{
public function index()
{
$attendances = Attendance::all();
return view('attendance.index', compact('attendances'));
}
public function create()
{
$users = User::all();
$courses = Course::all();
return view('attendance.create', compact('users', 'courses'));
}
public function store(Request $request)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'CourseId' => 'required|exists:courses,CourseId',
'AttendanceDate' => 'required|date',
'Status' => 'required|in:Present,Absent',
]);
Attendance::create($request->all());
return redirect()->route('attendance.index')->with('success', 'Attendance recorded successfully.');
}
public function show(Attendance $attendance)
{
return view('attendance.show', compact('attendance'));
}
public function edit(Attendance $attendance)
{
$users = User::all();
$courses = Course::all();
return view('attendance.edit', compact('attendance', 'users', 'courses'));
}
public function update(Request $request, Attendance $attendance)
{
$request->validate([
'User Id' => 'required|exists:users,User Id',
'CourseId' => 'required|exists:courses,CourseId',
'AttendanceDate' => 'required|date',
'Status' => 'required|in:Present,Absent',
]);
$attendance->update($request->all());
return redirect()->route('attendance.index')->with('success', 'Attendance updated successfully.');
}
public function destroy(Attendance $attendance)
{
$attendance->delete();
return redirect()->route('attendance.index')->with('success', 'Attendance deleted successfully.');
}
}

7. AssessmentController


namespace App\Http\Controllers;
use App\Models\Assessment;
use App\Models\Course;
use Illuminate\Http\Request;
class AssessmentController extends Controller
{
public function index()
{
$assessments = Assessment::all();
return view('assessments.index', compact('assessments'));
}
public function create()
{
$courses = Course::all();
return view('assessments.create', compact('courses'));
}
public function store(Request $request)
{
$request->validate([
'CourseId' => ' required|exists:courses,CourseId',
'AssessmentType' => 'required|max:50',
'DueDate' => 'required|date',
]);
Assessment::create($request->all());
return redirect()->route('assessments.index')->with('success', 'Assessment created successfully.');
}
public function show(Assessment $assessment)
{
return view('assessments.show', compact('assessment'));
}
public function edit(Assessment $assessment)
{
$courses = Course::all();
return view('assessments.edit', compact('assessment', 'courses'));
}
public function update(Request $request, Assessment $assessment)
{
$request->validate([
'CourseId' => 'required|exists:courses,CourseId',
'AssessmentType' => 'required|max:50',
'DueDate' => 'required|date',
]);
$assessment->update($request->all());
return redirect()->route('assessments.index')->with('success', 'Assessment updated successfully.');
}
public function destroy(Assessment $assessment)
{
$assessment->delete();
return redirect()->route('assessments.index')->with('success', 'Assessment deleted successfully.');
}
}

8. FeedbackController


namespace App\Http\Controllers;
use App\Models\Feedback;
use App\Models\Course;
use Illuminate\Http\Request;
class FeedbackController extends Controller
{
public function index()
{
$feedbacks = Feedback::all();
return view('feedback.index', compact('feedbacks'));
}
public function create()
{
$courses = Course::all();
return view('feedback.create', compact('courses'));
}
public function store(Request $request)
{
$request->validate([
'CourseId' => 'required|exists:courses,CourseId',
'FeedbackText' => 'required|max:500',
]);
Feedback::create($request->all());
return redirect()->route('feedback.index')->with('success', 'Feedback submitted successfully.');
}
public function show(Feedback $feedback)
{
return view('feedback.show', compact('feedback'));
}
public function edit(Feedback $feedback)
{
$courses = Course::all();
return view('feedback.edit', compact('feedback', 'courses'));
}
public function update(Request $request, Feedback $feedback)
{
$request->validate([
'CourseId' => 'required|exists:courses,CourseId',
'FeedbackText' => 'required|max:500',
]);
$feedback->update($request->all());
return redirect()->route('feedback.index')->with('success', 'Feedback updated successfully.');
}
public function destroy(Feedback $feedback)
{
$feedback->delete();
return redirect()->route('feedback.index')->with('success', 'Feedback deleted successfully.');
}
}

9. NotificationController


namespace App\Http\Controllers;
use App\Models\Notification;
use Illuminate\Http\Request;
class NotificationController extends Controller
{
public function index()
{
$notifications = Notification::all();
return view('notifications.index', compact('notifications'));
}
public function create()
{
return view('notifications.create');
}
public function store(Request $request)
{
$request->validate([
'Message' => 'required|max:255',
'User Id' => 'required|exists:users,User Id',
]);
Notification::create($request->all());
return redirect()->route('notifications.index')->with('success', 'Notification created successfully.');
}
public function show(Notification $notification)
{
return view('notifications.show', compact('notification'));
}
public function edit(Notification $notification)
{
return view('notifications.edit', compact('notification'));
}
public function update(Request $request, Notification $notification)
{
$request->validate([
'Message' => 'required|max:255',
]);
$notification->update($request->all());
return redirect()->route('notifications.index')->with('success', 'Notification updated successfully.');
}
public function destroy(Notification $notification)
{
$notification->delete();
return redirect()->route('notifications.index')->with('success', 'Notification deleted successfully.');
}
}

10. ResourceController


namespace App\Http\Controllers;
use App\Models\Resource;
use Illuminate\Http\Request;
class ResourceController extends Controller
{
public function index()
{
$resources = Resource::all();
return view('resources.index', compact('resources'));
}
public function create()
{
return view('resources.create');
}
public function store(Request $request)
{
$request->validate([
'ResourceName' => 'required|max:100',
'ResourceLink' => ' required|url|max:255',
]);
Resource::create($request->all());
return redirect()->route('resources.index')->with('success', 'Resource created successfully.');
}
public function show(Resource $resource)
{
return view('resources.show', compact('resource'));
}
public function edit(Resource $resource)
{
return view('resources.edit', compact('resource'));
}
public function update(Request $request, Resource $resource)
{
$request->validate([
'ResourceName' => 'required|max:100',
'ResourceLink' => 'required|url|max:255',
]);
$resource->update($request->all());
return redirect()->route('resources.index')->with('success', 'Resource updated successfully.');
}
public function destroy(Resource $resource)
{
$resource->delete();
return redirect()->route('resources.index')->with('success', 'Resource deleted successfully.');
}
}

11. ReportController


namespace App\Http\Controllers;
use App\Models\Report;
use Illuminate\Http\Request;
class ReportController extends Controller
{
public function index()
{
$reports = Report::all();
return view('reports.index', compact('reports'));
}
public function create()
{
return view('reports.create');
}
public function store(Request $request)
{
$request->validate([
'ReportTitle' => 'required|max:100',
'ReportContent' => 'required',
]);
Report::create($request->all());
return redirect()->route('reports.index')->with('success', 'Report created successfully.');
}
public function show(Report $report)
{
return view('reports.show', compact('report'));
}
public function edit(Report $report)
{
return view('reports.edit', compact('report'));
}
public function update(Request $request, Report $report)
{
$request->validate([
'ReportTitle' => 'required|max:100',
'ReportContent' => 'required',
]);
$report->update($request->all());
return redirect()->route('reports.index')->with('success', 'Report updated successfully.');
}
public function destroy(Report $report)
{
$report->delete();
return redirect()->route('reports.index')->with('success', 'Report deleted successfully.');
}
}

Step 12: Create Views for Remaining Controllers

You will need to create views for each of the remaining controllers similar to the User Controller views. Here's a brief outline of what you need to create:

Role Views: resources/views/roles/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Course Views: resources/views/courses/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Content Views: resources/views/content/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Schedule Views: resources/views/schedules/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Enrollment Views: resources/views/enrollments/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Attendance Views: resources/views/attendance/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Assessment Views: resources/views/assessments/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Feedback Views: resources/views/feedback/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Notification Views: resources/views/notifications/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Resource Views: resources/views/resources/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Report Views: resources/views/reports/index.blade.php, create.blade.php, edit.blade.php, show.blade.php

Step 13: Define Routes for Remaining Controllers

Ensure you define the routes for the remaining controllers in your routes/web.php file:


Route::resource('roles', RoleController::class);
Route::resource('courses', CourseController::class);
Route::resource('content', ContentController::class);
Route::resource('schedules', ScheduleController::class);
Route::resource('enrollments', EnrollmentController::class);
Route::resource('attendance', AttendanceController::class);
Route::resource('assessments', AssessmentController::class);
Route::resource('feedback', FeedbackController::class);
Route::resource('notifications', NotificationController::class);
Route::resource('resources', ResourceController::class);
Route::resource('reports', ReportController::class);

This completes the setup for the remaining controllers, including their CRUD operations and routes.

You can now implement the views for each controller as needed, following the structure provided for the User Controller. This will give you a fully functional CRUD interface for all specified models in your Laravel application.

Below are the view files for each controller, designed using Bootstrap 5.

1. User Views

resources/views/users/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Users</h1>
<a href="{{ route('users.create') }}" class="btn btn-primary mb-3">Create User</a>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Email</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->Username }}</td>
<td>{{ $user->Email }}</td>
<td>
<a href="{{ route('users.show', $user) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('users.edit', $user) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('users.destroy', $user) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/users/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create User</h1>
<form action="{{ route('users.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="Username" class="form-label">Username</label>
<input type="text" name="Username" class="form-control" required>
</div>
<div class="mb-3">
<label for="PasswordHash" class="form-label">Password</label>
<input type="password" name="PasswordHash" class="form-control" required>
</div>
<div class="mb-3">
<label for="Email" class="form-label">Email</label>
<input type="email" name="Email" class="form-control" required>
</div>
<div class="mb-3">
<label for="FirstName" class="form-label">First Name</label>
<input type="text" name="FirstName" class="form-control" required>
</div>
<div class="mb-3">
<label for="LastName" class="form-label">Last Name</label>
<input type="text" name="LastName" class="form-control" required>
</div>
<div class="mb-3">
<label for="RoleId" class="form-label">Role</label>
<select name="RoleId" class="form-select" required>
@foreach ($roles as $role)
<option value="{{ $role->RoleId }}">{{ $role->RoleName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/users/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit User</h1>
<form action="{{ route('users.update', $user) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="Username" class="form-label">Username</label>
<input type="text" name="Username" class="form-control" value="{{ $user->Username }}" required>
</div>
<div class="mb-3">
<label for="PasswordHash" class="form-label">Password</label>
<input type="password" name="PasswordHash" class="form-control">
<small class="form-text text-muted">Leave blank to keep the current password.</small>
</div>
<div class="mb-3">
<label for="Email" class="form-label">Email</label>
<input type="email" name="Email" class="form-control" value="{{ $user->Email }}" required>
</div>
<div class="mb-3">
<label for="FirstName" class="form-label">First Name</label>
<input type="text" name="FirstName" class="form-control" value="{{ $user->FirstName }}" required>
</div>
<div class="mb-3">
<label for="LastName" class="form-label">Last Name</label>
<input type="text" name="LastName" class="form-control" value="{{ $user->LastName }}" required>
</div>
<div class="mb-3">
<label for="RoleId" class="form-label">Role</label>
<select name="RoleId" class="form-select" required>
@foreach ($roles as $role)
<option value="{{ $role->RoleId }}" {{ $role->RoleId == $user->RoleId ? 'selected' : '' }}>{{ $role->RoleName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/users/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>User Details</h1>
<p><strong>Username:</strong> {{ $user->Username }}</p>
<p><strong>Email:</strong> {{ $user->Email }}</p>
<p><strong>First Name:</strong> {{ $user->FirstName }}</p>
<p><strong>Last Name:</strong> {{ $user->LastName }}</p>
<p><strong>Role:</strong> {{ $user->roles->RoleName }}</p>
<a href="{{ route('users.edit', $user) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('users.destroy', $user) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class=" btn btn-danger">Delete</button>
</form>
<a href="{{ route('users.index') }}" class="btn btn-secondary">Back to Users</a>
</div>
@endsection

2. Role Views

resources/views/roles/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Roles</h1>
<a href="{{ route('roles.create') }}" class="btn btn-primary mb-3">Create Role</a>
<table class="table">
<thead>
<tr>
<th>Role Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($roles as $role)
<tr>
<td>{{ $role->RoleName }}</td>
<td>
<a href="{{ route('roles.edit', $role) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('roles.destroy', $role) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/roles/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Role</h1>
<form action="{{ route('roles.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="RoleName" class="form-label">Role Name</label>
<input type="text" name="RoleName" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/roles/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Role</h1>
<form action="{{ route('roles.update', $role) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="RoleName" class="form-label">Role Name</label>
<input type="text" name="RoleName" class="form-control" value="{{ $role->RoleName }}" required>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/roles/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Role Details</h1>
<p><strong>Role Name:</strong> {{ $role->RoleName }}</p>
<a href="{{ route('roles.edit', $role) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('roles.destroy', $role) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('roles.index') }}" class="btn btn-secondary">Back to Roles</a>
</div>
@endsection

3. Course Views

resources/views/courses/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Courses</h1>
<a href="{{ route('courses.create') }}" class="btn btn-primary mb-3">Create Course</a>
<table class="table">
<thead>
<tr>
<th>Course Name</th>
<th>Description</th>
<th>Created By</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($courses as $course)
<tr>
<td>{{ $course->CourseName }}</td>
<td>{{ $course->Description }}</td>
<td>{{ $course->user->FirstName }} {{ $course->user->LastName }}</td>
<td>
<a href="{{ route('courses.show', $course) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('courses.edit', $course) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('courses.destroy', $course) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/courses/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Course</h1>
<form action="{{ route('courses.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="CourseName" class="form-label">Course Name</label>
<input type="text" name="CourseName" class="form-control" required>
</div>
<div class="mb-3">
<label for="Description" class="form-label">Description</label>
<textarea name="Description" class="form-control"></textarea>
</div>
<div class="mb-3">
<label for="CreatedBy" class="form-label">Created By</label>
<select name="CreatedBy" class="form-select" required>
@foreach ($users as $user)
<option value="{{ $user->User Id }}">{{ $user->FirstName }} {{ $user->LastName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/courses/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Course</h1>
<form action="{{ route('courses.update', $course) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="CourseName" class="form-label">Course Name</label>
<input type="text" name="CourseName" class="form-control" value="{{ $course->CourseName }}" required>
</div>
<div class="mb-3">
<label for="Description" class="form-label">Description</label>
<textarea name="Description" class="form-control">{{ $course->Description }}</textarea>
</div>
<div class="mb-3">
<label for="CreatedBy" class="form-label">Created By</label>
<select name="CreatedBy" class="form-select" required>
@foreach ($users as $user)
<option value="{{ $user->User Id }}" {{ $user->User Id == $course->CreatedBy ? 'selected' : '' }}>{{ $user->FirstName }} {{ $user->LastName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/courses/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Course Details</h1>
<p><strong>Course Name:</strong> {{ $course->CourseName }}</p>
<p><strong>Description:</strong> {{ $course->Description }}</p>
<p><strong>Created By:</strong> {{ $course->user->FirstName }} {{ $course->user->LastName }}</p>
<a href="{{ route('courses.edit', $course) }}" class="btn btn-warning">Edit</a>
<form action="{{ route(' courses.destroy', $course) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('courses.index') }}" class="btn btn-secondary">Back to Courses</a>
</div>
@endsection

4. Content Views

resources/views/content/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Content</h1>
<a href="{{ route('content.create') }}" class="btn btn-primary mb-3">Create Content</a>
<table class="table">
<thead>
<tr>
<th>Course</th>
<th>Content Type</th>
<th>Content Link</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($contents as $content)
<tr>
<td>{{ $content->course->CourseName }}</td>
<td>{{ $content->ContentType }}</td>
<td><a href="{{ $content->ContentLink }}" target="_blank">{{ $content->ContentLink }}</a></td>
<td>
<a href="{{ route('content.show', $content) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('content.edit', $content) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('content.destroy', $content) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/content/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Content</h1>
<form action="{{ route('content.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}">{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="ContentType" class="form-label">Content Type</label>
<input type="text" name="ContentType" class="form-control" required>
</div>
<div class="mb-3">
<label for="ContentLink" class="form-label">Content Link</label>
<input type="url" name="ContentLink" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/content/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Content</h1>
<form action="{{ route('content.update', $content) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}" {{ $course->CourseId == $content->CourseId ? 'selected' : '' }}>{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="ContentType" class="form-label">Content Type</label>
<input type="text" name="ContentType" class="form-control" value="{{ $content->ContentType }}" required>
</div>
<div class="mb-3">
<label for="ContentLink" class="form-label">Content Link</label>
<input type="url" name="ContentLink" class="form-control" value="{{ $content->ContentLink }}">
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/content/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Content Details</h1>
<p><strong>Course:</strong> {{ $content->course->CourseName }}</p>
<p><strong>Content Type:</strong> {{ $content->ContentType }}</p>
<p><strong>Content Link:</strong> <a href="{{ $content->ContentLink }}" target="_blank">{{ $content->ContentLink }}</a></p>
<a href="{{ route('content.edit', $content) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('content.destroy', $content) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('content.index') }}" class="btn btn-secondary">Back to Content</a>
</div>
@endsection

5. Schedule Views

resources/views/schedules/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Schedules</h1>
<a href="{{ route('schedules.create') }}" class="btn btn-primary mb-3">Create Schedule</a>
<table class="table">
<thead>
<tr>
<th>Course</th>
<th>Start Date</th>
<th>End Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($schedules as $schedule)
<tr>
<td>{{ $schedule->course->CourseName }}</td>
<td>{{ $schedule->StartDate }}</td>
<td>{{ $schedule->EndDate }}</td>
<td>
<a href="{{ route('schedules.show', $schedule) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('schedules.edit', $schedule) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('schedules.destroy', $schedule) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/schedules/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Schedule</h1>
<form action="{{ route('schedules.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}">{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="StartDate" class="form-label">Start Date</label>
<input type="date" name="StartDate" class="form-control" required>
</div>
<div class="mb-3">
<label for="EndDate" class="form-label">End Date</label>
<input type="date" name="EndDate" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/schedules/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Schedule</h1>
<form action="{{ route('schedules.update', $schedule) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}" {{ $course->CourseId == $schedule->CourseId ? 'selected' : '' }}>{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="StartDate" class="form-label">Start Date</label>
<input type="date" name="StartDate" class="form-control" value="{{ $schedule->StartDate }}" required>
</div>
<div class="mb-3">
<label for="EndDate" class="form-label ">End Date</label>
<input type="date" name="EndDate" class="form-control" value="{{ $schedule->EndDate }}" required>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/schedules/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Schedule Details</h1>
<p><strong>Course:</strong> {{ $schedule->course->CourseName }}</p>
<p><strong>Start Date:</strong> {{ $schedule->StartDate }}</p>
<p><strong>End Date:</strong> {{ $schedule->EndDate }}</p>
<a href="{{ route('schedules.edit', $schedule) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('schedules.destroy', $schedule) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('schedules.index') }}" class="btn btn-secondary">Back to Schedules</a>
</div>
@endsection

6. Enrollment Views

resources/views/enrollments/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Enrollments</h1>
<a href="{{ route('enrollments.create') }}" class="btn btn-primary mb-3">Create Enrollment</a>
<table class="table">
<thead>
<tr>
<th>User</th>
<th>Course</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($enrollments as $enrollment)
<tr>
<td>{{ $enrollment->user->FirstName }} {{ $enrollment->user->LastName }}</td>
<td>{{ $enrollment->course->CourseName }}</td>
<td>
<a href="{{ route('enrollments.show', $enrollment) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('enrollments.edit', $enrollment) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('enrollments.destroy', $enrollment) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/enrollments/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Enrollment</h1>
<form action="{{ route('enrollments.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select name="User Id" class="form-select" required>
@foreach ($users as $user)
<option value="{{ $user->User Id }}">{{ $user->FirstName }} {{ $user->LastName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}">{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/enrollments/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Enrollment</h1>
<form action="{{ route('enrollments.update', $enrollment) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select name="User Id" class="form-select" required>
@foreach ($users as $user)
<option value="{{ $user->User Id }}" {{ $user->User Id == $enrollment->User Id ? 'selected' : '' }}>{{ $user->FirstName }} {{ $user-> LastName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}" {{ $course->CourseId == $enrollment->CourseId ? 'selected' : '' }}>{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/enrollments/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Enrollment Details</h1>
<p><strong>User:</strong> {{ $enrollment->user->FirstName }} {{ $enrollment->user->LastName }}</p>
<p><strong>Course:</strong> {{ $enrollment->course->CourseName }}</p>
<a href="{{ route('enrollments.edit', $enrollment) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('enrollments.destroy', $enrollment) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('enrollments.index') }}" class="btn btn-secondary">Back to Enrollments</a>
</div>
@endsection

7. Attendance Views

resources/views/attendance/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Attendance</h1>
<a href="{{ route('attendance.create') }}" class="btn btn-primary mb-3">Record Attendance</a>
<table class="table">
<thead>
<tr>
<th>User</th>
<th>Course</th>
<th>Attendance Date</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($attendances as $attendance)
<tr>
<td>{{ $attendance->user->FirstName }} {{ $attendance->user->LastName }}</td>
<td>{{ $attendance->course->CourseName }}</td>
<td>{{ $attendance->AttendanceDate }}</td>
<td>{{ $attendance->Status }}</td>
<td>
<a href="{{ route('attendance.show', $attendance) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('attendance.edit', $attendance) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('attendance.destroy', $attendance) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/attendance/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Record Attendance</h1>
<form action="{{ route('attendance.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select name="User Id" class="form-select" required>
@foreach ($users as $user)
<option value="{{ $user->User Id }}">{{ $user->FirstName }} {{ $user->LastName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}">{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="AttendanceDate" class="form-label">Attendance Date</label>
<input type="date" name="AttendanceDate" class="form-control" required>
</div>
<div class="mb-3">
<label for="Status" class="form-label">Status</label>
<select name="Status" class="form-select " required>
<option value="Present">Present</option>
<option value="Absent">Absent</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Record Attendance</button>
</form>
</div>
@endsection

resources/views/attendance/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Attendance</h1>
<form action="{{ route('attendance.update', $attendance) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select name="User Id" class="form-select" required>
@foreach ($users as $user)
<option value="{{ $user->User Id }}" {{ $user->User Id == $attendance->User Id ? 'selected' : '' }}>{{ $user->FirstName }} {{ $user->LastName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}" {{ $course->CourseId == $attendance->CourseId ? 'selected' : '' }}>{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="AttendanceDate" class="form-label">Attendance Date</label>
<input type="date" name="AttendanceDate" class="form-control" value="{{ $attendance->AttendanceDate }}" required>
</div>
<div class="mb-3">
<label for="Status" class="form-label">Status</label>
<select name="Status" class="form-select" required>
<option value="Present" {{ $attendance->Status == 'Present' ? 'selected' : '' }}>Present</option>
<option value="Absent" {{ $attendance->Status == 'Absent' ? 'selected' : '' }}>Absent</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Update Attendance</button>
</form>
</div>
@endsection

resources/views/attendance/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Attendance Details</h1>
<p><strong>User:</strong> {{ $attendance->user->FirstName }} {{ $attendance->user->LastName }}</p>
<p><strong>Course:</strong> {{ $attendance->course->CourseName }}</p>
<p><strong>Attendance Date:</strong> {{ $attendance->AttendanceDate }}</p>
<p><strong>Status:</strong> {{ $attendance->Status }}</p>
<a href="{{ route('attendance.edit', $attendance) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('attendance.destroy', $attendance) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('attendance.index') }}" class="btn btn-secondary">Back to Attendance</a>
</div>
@endsection

8. Assessment Views

resources/views/assessments/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Assessments</h1>
<a href="{{ route('assessments.create') }}" class="btn btn-primary mb-3">Create Assessment</a>
<table class="table">
<thead>
<tr>
<th>Course</th>
<th>Assessment Type</th>
<th>Due Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($assessments as $assessment)
<tr>
<td>{{ $assessment->course->CourseName }}</td>
<td>{{ $assessment->AssessmentType }}</td>
<td>{{ $assessment->DueDate }}</td>
<td>
<a href="{{ route('assessments.show', $assessment) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('assessments.edit', $assessment) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('assessments .destroy', $assessment) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/assessments/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Assessment</h1>
<form action="{{ route('assessments.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}">{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="AssessmentType" class="form-label">Assessment Type</label>
<input type="text" name="AssessmentType" class="form-control" required>
</div>
<div class="mb-3">
<label for="DueDate" class="form-label">Due Date</label>
<input type="date" name="DueDate" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/assessments/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Assessment</h1>
<form action="{{ route('assessments.update', $assessment) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}" {{ $course->CourseId == $assessment->CourseId ? 'selected' : '' }}>{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="AssessmentType" class="form-label">Assessment Type</label>
<input type="text" name="AssessmentType" class="form-control" value="{{ $assessment->AssessmentType }}" required>
</div>
<div class="mb-3">
<label for="DueDate" class="form-label">Due Date</label>
<input type="date" name="DueDate" class="form-control" value="{{ $assessment->DueDate }}" required>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/assessments/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Assessment Details</h1>
<p><strong>Course:</strong> {{ $assessment->course->CourseName }}</p>
<p><strong>Assessment Type:</strong> {{ $assessment->AssessmentType }}</p>
<p><strong>Due Date:</strong> {{ $assessment->DueDate }}</p>
<a href="{{ route('assessments.edit', $assessment) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('assessments.destroy', $assessment) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('assessments.index') }}" class="btn btn-secondary">Back to Assessments</a>
</div>
@endsection

9. Feedback Views

resources/views/feedback/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Feedback</h1>
<a href="{{ route('feedback.create') }}" class="btn btn-primary mb-3">Submit Feedback</a>
<table class="table">
<thead>
<tr>
<th>Course</th>
<th>Feedback</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($feedbacks as $feedback)
<tr>
<td>{{ $feedback->course->CourseName }}</td>
<td>{{ $feedback->FeedbackText }}</td>
<td>
<a href="{{ route('feedback.show', $feedback) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('feedback.edit', $feedback) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('feedback.destroy', $feedback) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/feedback/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Submit Feedback</h1>
<form action="{{ route('feedback.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}">{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="FeedbackText" class="form-label">Feedback</label>
<textarea name="FeedbackText" class="form-control" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit Feedback</button>
</form>
</div>
@endsection

resources/views/feedback/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Feedback</h1>
<form action="{{ route('feedback.update', $feedback) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="CourseId" class="form-label">Course</label>
<select name="CourseId" class="form-select" required>
@foreach ($courses as $course)
<option value="{{ $course->CourseId }}" {{ $course->CourseId == $feedback->CourseId ? 'selected' : '' }}>{{ $course->CourseName }}</option>
@endforeach
</select>
</div>
<div class="mb-3">
<label for="FeedbackText" class="form-label">Feedback</label>
<textarea name="FeedbackText" class="form-control" required>{{ $feedback->FeedbackText }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Update Feedback</button>
</form>
</div>
@endsection

resources/views/feedback/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Feedback Details</h1>
<p><strong>Course:</strong> {{ $feedback->course->CourseName }}</p>
<p><strong>Feedback:</strong> {{ $feedback->FeedbackText }}</p>
<a href="{{ route('feedback.edit', $feedback) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('feedback.destroy', $feedback) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('feedback.index') }}" class="btn btn-secondary">Back to Feedback</a>
</div>
@endsection

10. Notification Views

resources/views/notifications/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Notifications</h1>
<a href="{{ route('notifications.create') }}" class="btn btn-primary mb-3">Create Notification</a>
<table class="table">
<thead>
<tr>
<th>Message</th>
<th>User</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($notifications as $notification)
<tr>
<td>{{ $notification->Message }}</td>
<td>{{ $notification->user->FirstName }} {{ $notification->user->LastName }}</td>
<td>
<a href="{{ route('notifications.show', $notification) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('notifications.edit', $notification) }}" class="btn btn-warning btn-sm"> Edit</a>
<form action="{{ route('notifications.destroy', $notification) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/notifications/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Notification</h1>
<form action="{{ route('notifications.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="Message" class="form-label">Message</label>
<input type="text" name="Message" class="form-control" required>
</div>
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select name="User Id" class="form-select" required>
@foreach ($users as $user)
<option value="{{ $user->User Id }}">{{ $user->FirstName }} {{ $user->LastName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/notifications/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Notification</h1>
<form action="{{ route('notifications.update', $notification) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="Message" class="form-label">Message</label>
<input type="text" name="Message" class="form-control" value="{{ $notification->Message }}" required>
</div>
<div class="mb-3">
<label for="User Id" class="form-label">User </label>
<select name="User Id" class="form-select" required>
@foreach ($users as $user)
<option value="{{ $user->User Id }}" {{ $user->User Id == $notification->User Id ? 'selected' : '' }}>{{ $user->FirstName }} {{ $user->LastName }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/notifications/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Notification Details</h1>
<p><strong>Message:</strong> {{ $notification->Message }}</p>
<p><strong>User:</strong> {{ $notification->user->FirstName }} {{ $notification->user->LastName }}</p>
<a href="{{ route('notifications.edit', $notification) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('notifications.destroy', $notification) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('notifications.index') }}" class="btn btn-secondary">Back to Notifications</a>
</div>
@endsection

11. Resource Views

resources/views/resources/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Resources</h1>
<a href="{{ route('resources.create') }}" class="btn btn-primary mb-3">Create Resource</a>
<table class="table">
<thead>
<tr>
<th>Resource Name</th>
<th>Resource Link</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($resources as $resource)
<tr>
<td>{{ $resource->ResourceName }}</td>
<td><a href="{{ $resource->ResourceLink }}" target="_blank">{{ $resource->ResourceLink }}</a></td>
<td>
<a href="{{ route('resources.show', $resource) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('resources.edit', $resource) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('resources.destroy', $resource) }}" method="POST" style="display:inline;">
@csrf
@ method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/resources/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Resource</h1>
<form action="{{ route('resources.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="ResourceName" class="form-label">Resource Name</label>
<input type="text" name="ResourceName" class="form-control" required>
</div>
<div class="mb-3">
<label for="ResourceLink" class="form-label">Resource Link</label>
<input type="url" name="ResourceLink" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/resources/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Resource</h1>
<form action="{{ route('resources.update', $resource) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="ResourceName" class="form-label">Resource Name</label>
<input type="text" name="ResourceName" class="form-control" value="{{ $resource->ResourceName }}" required>
</div>
<div class="mb-3">
<label for="ResourceLink" class="form-label">Resource Link</label>
<input type="url" name="ResourceLink" class="form-control" value="{{ $resource->ResourceLink }}" required>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/resources/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Resource Details</h1>
<p><strong>Resource Name:</strong> {{ $resource->ResourceName }}</p>
<p><strong>Resource Link:</strong> <a href="{{ $resource->ResourceLink }}" target="_blank">{{ $resource->ResourceLink }}</a></p>
<a href="{{ route('resources.edit', $resource) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('resources.destroy', $resource) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('resources.index') }}" class="btn btn-secondary">Back to Resources</a>
</div>
@endsection

12. Report Views

resources/views/reports/index.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Reports</h1>
<a href="{{ route('reports.create') }}" class="btn btn-primary mb-3">Create Report</a>
<table class="table">
<thead>
<tr>
<th>Report Title</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($reports as $report)
<tr>
<td>{{ $report->ReportTitle }}</td>
<td>
<a href="{{ route('reports.show', $report) }}" class="btn btn-info btn-sm">View</a>
<a href="{{ route('reports.edit', $report) }}" class="btn btn-warning btn-sm">Edit</a>
<form action="{{ route('reports.destroy', $report) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection

resources/views/reports/create.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create Report</h1>
<form action="{{ route('reports.store') }}" method="POST">
@csrf
<div class="mb-3">
<label for="ReportTitle" class="form-label">Report Title</label>
<input type="text" name="ReportTitle" class=" form-control" required>
</div>
<div class="mb-3">
<label for="ReportContent" class="form-label">Report Content</label>
<textarea name="ReportContent" class="form-control" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
@endsection

resources/views/reports/edit.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Edit Report</h1>
<form action="{{ route('reports.update', $report) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="ReportTitle" class="form-label">Report Title</label>
<input type="text" name="ReportTitle" class="form-control" value="{{ $report->ReportTitle }}" required>
</div>
<div class="mb-3">
<label for="ReportContent" class="form-label">Report Content</label>
<textarea name="ReportContent" class="form-control" required>{{ $report->ReportContent }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
@endsection

resources/views/reports/show.blade.php


@extends('layouts.app')
@section('content')
<div class="container">
<h1>Report Details</h1>
<p><strong>Report Title:</strong> {{ $report->ReportTitle }}</p>
<p><strong>Report Content:</strong> {{ $report->ReportContent }}</p>
<a href="{{ route('reports.edit', $report) }}" class="btn btn-warning">Edit</a>
<form action="{{ route('reports.destroy', $report) }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
<a href="{{ route('reports.index') }}" class="btn btn-secondary">Back to Reports</a>
</div>
@endsection

This completes the view files for all controllers, utilizing Bootstrap 5 for styling and layout.

Each view includes the necessary forms and tables to facilitate CRUD operations for the respective models.

To create a layout view file in Laravel that can be used across your application, you typically create a file named app.blade.php (or similar) in the resources/views/layouts directory.

This layout will include the common HTML structure, Bootstrap 5 CSS, and any other necessary scripts or styles.

Here's an example of a basic layout view file using Bootstrap 5:

resources/views/layouts/app.blade.php


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title', 'My Application')</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="{{ asset('css/app.css') }}"> <!-- Optional custom CSS -->
@yield('styles') <!-- For additional styles -->
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="{{ url('/') }}">My Application</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{{ route('users.index') }}">Users</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('roles.index') }}">Roles</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('courses.index') }}">Courses</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('content.index') }}">Content</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('schedules.index') }}">Schedules</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('enrollments.index') }}">Enrollments</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('attendance.index') }}">Attendance</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('assessments.index') }}">Assessments</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('feedback.index') }}">Feedback</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('notifications.index') }}">Notifications</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('resources.index') }}">Resources</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('reports.index') }}">Reports</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-4">
@if(session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@endif
@if(session('error'))
<div class="alert alert-danger">
{{ session('error') }}
</div>
@endif
@yield('content')
</div>
<footer class="bg-light text-center text-lg-start mt-4">
<div class="text-center p-3">
© 2023 My Application
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js"></script>
@yield('scripts') <!-- For additional scripts -->
</body>
</html>

Explanation of the Layout File

HTML Structure: The layout file includes the basic HTML structure with a <head> section for metadata and links to Bootstrap CSS.

Navigation Bar: A responsive navigation bar is created using Bootstrap classes. It includes links to various sections of the application (like Users, Roles, Courses, etc.).

Content Section: The @yield('content') directive is where the content of individual views will be injected.

Alerts: Success and error messages are displayed using Bootstrap alert classes.

Footer: A simple footer is included at the bottom of the page.

Scripts: Bootstrap's JavaScript and Popper.js are included at the end of the body for better performance.

Using the Layout

To use this layout in your views, you can extend it at the top of your view files like this:


@extends('layouts.app')
@section('title', 'Page Title')
@section('content')
<!-- Your page content goes here -->
@endsection

To create a dashboard page in your Laravel application that displays consolidated data related to your project, you will need to follow these steps:

Create a Route for the Dashboard: Define a route in your routes/web.php file.

Create a Controller Method: Create a method in a controller to fetch the necessary data.

Create a Dashboard View: Create a view file to display the dashboard.

Fetch and Display Data: In the controller, fetch the data from the database and pass it to the view.

Step 1: Create a Route for the Dashboard

Add the following route to your routes/web.php file:


use App\Http\Controllers\DashboardController;
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');

Step 2: Create a Controller Method

You can create a new controller for the dashboard or use an existing one. Here, I will create a new DashboardController.

Run the following command to create the controller:


php artisan make:controller DashboardController

Then, add the following method to the DashboardController:


namespace App\Http\Controllers;
use App\Models\User;
use App\Models\Role;
use App\Models\Course;
use App\Models\Enrollment;
use App\Models\Feedback;
use App\Models\Attendance;
use Illuminate\Http\Request;
class DashboardController extends Controller
{
public function index()
{
$userCount = User::count();
$roleCount = Role::count();
$courseCount = Course::count();
$enrollmentCount = Enrollment::count();
$feedbackCount = Feedback::count();
$attendanceCount = Attendance::count();
return view('dashboard.index', compact(
'userCount',
'roleCount',
'courseCount',
'enrollmentCount',
'feedbackCount',
'attendanceCount'
));
}
}

Step 3: Create a Dashboard View
Create a new view file for the dashboard at resources/views/dashboard/index.blade.php:

@extends('layouts.app')
@section('title', 'Dashboard')
@section('content')
<div class="container">
<h1>Dashboard</h1>
<div class="row">
<div class="col-md-4">
<div class="card text-white bg-primary mb-3">
<div class="card-header">Total Users</div>
<div class="card-body">
<h5 class="card-title">{{ $userCount }}</h5>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-white bg-success mb-3">
<div class="card-header">Total Roles</div>
<div class="card-body">
<h5 class="card-title">{{ $roleCount }}</h5>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-white bg-info mb-3">
<div class="card-header">Total Courses</div>
<div class="card-body">
<h5 class="card-title">{{ $courseCount }}</h5>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="card text-white bg-warning mb-3">
<div class="card-header">Total Enrollments</div>
<div class="card-body">
<h5 class="card-title">{{ $enrollmentCount }}</h5>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-white bg-danger mb-3">
<div class="card-header">Total Feedback</div>
<div class="card-body">
<h5 class="card-title">{{ $feedbackCount }}</h5>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card text-white bg-secondary mb-3">
<div class="card-header">Total Attendance Records</div>
<div class="card-body">
<h5 class="card-title">{{ $attendanceCount }}</h5>
</div>
</div>
</div>
</div>
</div>
@endsection

Step 4: Access the Dashboard

Now that you have set up the route, controller, and view, you can access the dashboard by navigating to /dashboard in your web browser.

Summary

The dashboard page will display the total counts of users, roles, courses, enrollments, feedback, and attendance records using Bootstrap cards for a clean and organized layout.

You can further enhance the dashboard by adding charts, graphs, or other visual elements to represent the data more effectively.