From d63e9c0a2b4d50be9146dfe5f4867c298615788f Mon Sep 17 00:00:00 2001
From: imadhigp
Date: Tue, 28 Jul 2026 16:46:11 +0530
Subject: [PATCH] set courese backend
---
app/Http/Controllers/applyController.php | 57 +++++-
app/Http/Controllers/coursesController.php | 11 +-
app/Models/Application.php | 48 +++++
app/Models/courses.php | 24 ++-
...07_28_064543_create_applications_table.php | 59 ++++++
resources/views/abouts.blade.php | 4 +-
resources/views/apply.blade.php | 19 +-
resources/views/courses.blade.php | 188 ++++++------------
resources/views/welcome.blade.php | 72 ++++++-
routes/web.php | 10 +-
10 files changed, 347 insertions(+), 145 deletions(-)
create mode 100644 app/Models/Application.php
create mode 100644 database/migrations/2026_07_28_064543_create_applications_table.php
diff --git a/app/Http/Controllers/applyController.php b/app/Http/Controllers/applyController.php
index 8e342f1..b5f1886 100644
--- a/app/Http/Controllers/applyController.php
+++ b/app/Http/Controllers/applyController.php
@@ -2,9 +2,60 @@
namespace App\Http\Controllers;
+use App\Models\Application;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
-class applyController extends Controller
+class ApplyController extends Controller
{
- //
-}
+ public function index()
+ {
+ return view('apply'); // Tawa name ekak nam view name eka wenas karanna
+ }
+
+ public function store(Request $request)
+ {
+ // 1. Data Validation Rules
+ $validatedData = $request->validate([
+ 'first_name' => 'required|string|max:255',
+ 'last_name' => 'required|string|max:255',
+ 'nic' => 'nullable|string|max:50',
+ 'nationality' => 'nullable|string|max:100',
+ 'address' => 'required|string|max:500',
+ 'state' => 'required|string|max:255',
+ 'gender' => 'nullable|string',
+ 'dob' => 'nullable|date',
+ 'mobile' => 'required|string|max:20',
+ 'mobile2' => 'nullable|string|max:20',
+ 'email' => 'required|email|max:255',
+ 'preferred_contact_method' => 'nullable|string',
+ 'still_at_school' => 'nullable|string',
+ 'highest_qualification' => 'nullable|string',
+ 'school_name' => 'nullable|string|max:255',
+ 'year_completed' => 'nullable|numeric|digits:4',
+ 'exam_passed' => 'nullable|string',
+ 'subjects' => 'nullable|string|max:255',
+ 'grades_results' => 'nullable|string',
+ 'certificates.*' => 'nullable|file|mimes:pdf,jpg,jpeg,png|max:5120', // Max 5MB per file
+ 'emergency_contact_name' => 'required|string|max:255',
+ 'emergency_contact_relationship' => 'required|string|max:255',
+ ]);
+
+ // 2. Multi File Upload Process
+ $certificatePaths = [];
+ if ($request->hasFile('certificates')) {
+ foreach ($request->file('certificates') as $file) {
+ $path = $file->store('certificates', 'public');
+ $certificatePaths[] = $path;
+ }
+ }
+
+ // 3. Current Logged-in User ID එක set කිරීම & Data Save කිරීම
+ $application = new Application($validatedData);
+ $application->user_id = Auth::id(); // Log unukena ge ID eka attach wei
+ $application->certificates = $certificatePaths; // Paths array eka save wei
+ $application->save();
+
+ return redirect()->back()->with('success', 'Your application has been submitted successfully!');
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/coursesController.php b/app/Http/Controllers/coursesController.php
index a92fdce..caae79b 100644
--- a/app/Http/Controllers/coursesController.php
+++ b/app/Http/Controllers/coursesController.php
@@ -2,9 +2,16 @@
namespace App\Http\Controllers;
+use App\Models\courses;
use Illuminate\Http\Request;
class coursesController extends Controller
{
- //
-}
+ public function index()
+ {
+
+ $courses = courses::all();
+
+ return view('courses', compact('courses'));
+ }
+}
\ No newline at end of file
diff --git a/app/Models/Application.php b/app/Models/Application.php
new file mode 100644
index 0000000..48aa89f
--- /dev/null
+++ b/app/Models/Application.php
@@ -0,0 +1,48 @@
+ 'array',
+ 'dob' => 'date',
+ ];
+
+ public function user()
+ {
+ return $this->belongsTo(User::class);
+ }
+}
\ No newline at end of file
diff --git a/app/Models/courses.php b/app/Models/courses.php
index b3a1479..b5d4bd3 100644
--- a/app/Models/courses.php
+++ b/app/Models/courses.php
@@ -2,9 +2,29 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class courses extends Model
{
- //
-}
+ use HasFactory;
+
+
+ protected $table = 'courses';
+
+
+ protected $fillable = [
+ 'title',
+ 'image',
+ 'duration',
+ 'level',
+ 'author',
+ 'desc',
+ 'student',
+ 'rating',
+ 'badge',
+ 'trending',
+ 'course_code',
+ 'status'
+ ];
+}
\ No newline at end of file
diff --git a/database/migrations/2026_07_28_064543_create_applications_table.php b/database/migrations/2026_07_28_064543_create_applications_table.php
new file mode 100644
index 0000000..690a4b0
--- /dev/null
+++ b/database/migrations/2026_07_28_064543_create_applications_table.php
@@ -0,0 +1,59 @@
+id();
+ $table->foreignId('user_id')->constrained()->onDelete('cascade');
+
+ // Student Info
+ $table->string('first_name');
+ $table->string('last_name');
+ $table->string('nic')->nullable();
+ $table->string('nationality')->nullable();
+ $table->string('address');
+ $table->string('state');
+ $table->string('gender')->nullable();
+ $table->date('dob')->nullable();
+
+ // Contact Info
+ $table->string('mobile');
+ $table->string('mobile2')->nullable();
+ $table->string('email');
+ $table->string('preferred_contact_method')->nullable();
+
+ // Academic Qualifications
+ $table->string('still_at_school')->nullable();
+ $table->string('highest_qualification')->nullable();
+ $table->string('school_name')->nullable();
+ $table->integer('year_completed')->nullable();
+ $table->string('exam_passed')->nullable();
+ $table->string('subjects')->nullable();
+ $table->text('grades_results')->nullable();
+ $table->json('certificates')->nullable(); // Multi-file paths JSON row එකක් ලෙස
+
+ // Emergency Contacts
+ $table->string('emergency_contact_name');
+ $table->string('emergency_contact_relationship');
+
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('applications');
+ }
+};
diff --git a/resources/views/abouts.blade.php b/resources/views/abouts.blade.php
index f24041a..9e0e0f2 100644
--- a/resources/views/abouts.blade.php
+++ b/resources/views/abouts.blade.php
@@ -212,7 +212,7 @@ body {
We focus on building skilled professionals who are ready for
the global automotive industry.
-
+
View Courses@extends('layouts.app')
@section('title','About Us')
@@ -418,7 +418,7 @@ body {
We focus on building skilled professionals who are ready for
the global automotive industry.
-
+
View Courses
diff --git a/resources/views/apply.blade.php b/resources/views/apply.blade.php
index 3392212..f326f5c 100644
--- a/resources/views/apply.blade.php
+++ b/resources/views/apply.blade.php
@@ -166,7 +166,24 @@