Feat: Iv organised

This commit is contained in:
Sallu9007
2025-03-24 03:19:29 +05:30
parent 98522c4213
commit a20569c43a
11 changed files with 1074 additions and 65 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ActivitiesAttended;
use App\Models\ActivitiesOrganised;
use App\Models\IvOrganised;
class FacultyController extends Controller
{
@@ -36,6 +37,17 @@ class FacultyController extends Controller
return view('activities-organised.index');
}
public function IvOrganisedForm()
{
// Logic to show the response form
return view('faculty.iv-organised-form');
}
public function viewIvOrganisedResponses()
{
return view('iv-organised.index');
}
public function ActivitiesAttendedFormResponse(Request $request)
{
// dd($request->all(),"hello");
@@ -62,7 +74,6 @@ class FacultyController extends Controller
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
// Handle the file upload
// Handle the file upload
$proofPath = null;
if ($request->hasFile('proof')) {
@@ -74,7 +85,7 @@ class FacultyController extends Controller
$year = date('Y', strtotime($validated['start_date']));
// Create path structure: year/faculty_name
$folderPath = 'proofs/' . $year . '/' . $username;
$folderPath = 'proofs/' . $year . '/' . $username . 'Activities-Attended';
// Store file in the specified path
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
@@ -107,75 +118,143 @@ class FacultyController extends Controller
}
public function ActivitiesOrganisedFormResponse(Request $request)
{
try {
// Validate the request data
$validated = $request->validate([
'title' => 'required|string',
'resource_person_name' => 'required|string',
'resource_person_organization' => 'required|string',
'target_audience' => 'required|string',
'number_of_participants' => 'required|integer',
'objective' => 'required|string',
'outcomes' => 'required|string',
'venue' => 'required|string',
'start_date' => 'required|date',
'start_time' => 'required|date_format:H:i',
'end_date' => 'required|date',
'end_time' => 'required|date_format:H:i',
'num_days' => 'required|integer',
'activity_type' => 'required|string',
'category' => 'required|string',
'level' => 'required|string',
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
]);
{
try {
// Validate the request data
$validated = $request->validate([
'title' => 'required|string',
'resource_person_name' => 'required|string',
'resource_person_organization' => 'required|string',
'target_audience' => 'required|string',
'number_of_participants' => 'required|integer',
'objective' => 'required|string',
'outcomes' => 'required|string',
'venue' => 'required|string',
'start_date' => 'required|date',
'start_time' => 'required|date_format:H:i',
'end_date' => 'required|date',
'end_time' => 'required|date_format:H:i',
'num_days' => 'required|integer',
'activity_type' => 'required|string',
'category' => 'required|string',
'level' => 'required|string',
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
]);
// Combine start date and time
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
// Combine start date and time
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
// Handle the file upload
$proofPath = null;
if ($request->hasFile('proof')) {
$originalName = $request->file('proof')->getClientOriginalName();
$username = auth()->user()->name;
$fileName = $username . '_' . $originalName;
// Handle the file upload
$proofPath = null;
if ($request->hasFile('proof')) {
$originalName = $request->file('proof')->getClientOriginalName();
$username = auth()->user()->name;
$fileName = $username . '_' . $originalName;
// Extract year from start_date
$year = date('Y', strtotime($validated['start_date']));
// Extract year from start_date
$year = date('Y', strtotime($validated['start_date']));
// Create path structure: year/faculty_name
$folderPath = 'proofs/' . $year . '/' . $username;
// Create path structure: year/faculty_name
$folderPath = 'proofs/' . $year . '/' . $username . 'Activities-Organised';
// Store file in the specified path
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
// Store file in the specified path
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
}
// Save the response to the database
ActivitiesOrganised::create([
'title' => $validated['title'],
'resource_person_name' => $validated['resource_person_name'],
'resource_person_organization' => $validated['resource_person_organization'],
'target_audience' => $validated['target_audience'],
'number_of_participants' => $validated['number_of_participants'],
'objective' => $validated['objective'],
'outcomes' => $validated['outcomes'],
'department_id' => auth()->user()->department->id,
'faculty_id' => auth()->user()->id,
'venue' => $validated['venue'],
'start_date' => $startDateTime,
'end_date' => $endDateTime,
'num_days' => $validated['num_days'],
'activity_type' => $validated['activity_type'],
'category' => $validated['category'],
'level' => $validated['level'],
'proof' => $proofPath,
]);
return redirect()->route('faculty.dashboard')->with('status', 'Response submitted successfully');
} catch (\Exception $e) {
// Handle the exception and provide an error message
return back()->withErrors('An error occurred while submitting your response: ' . $e->getMessage());
}
}
// Save the response to the database
ActivitiesOrganised::create([
'title' => $validated['title'],
'resource_person_name' => $validated['resource_person_name'],
'resource_person_organization' => $validated['resource_person_organization'],
'target_audience' => $validated['target_audience'],
'number_of_participants' => $validated['number_of_participants'],
'objective' => $validated['objective'],
'outcomes' => $validated['outcomes'],
'department_id' => auth()->user()->department->id,
'faculty_id' => auth()->user()->id,
'venue' => $validated['venue'],
'start_date' => $startDateTime,
'end_date' => $endDateTime,
'num_days' => $validated['num_days'],
'activity_type' => $validated['activity_type'],
'category' => $validated['category'],
'level' => $validated['level'],
'proof' => $proofPath,
]);
public function IvOrganisedFormResponse(Request $request)
{
try {
// Validate the request data
$validated = $request->validate([
'faculty_id' => 'required|exists:users,id',
'start_date' => 'required|date',
'start_time' => 'required|date_format:H:i',
'end_date' => 'required|date',
'end_time' => 'required|date_format:H:i',
'company_name' => 'required|string',
'company_address' => 'required|string',
'resource_person_name' => 'required|string',
'resource_person_contact_details' => 'required|string',
'target_audience' => 'required|string',
'student_year' => 'nullable|string',
'number_of_participants' => 'required|integer',
'objective' => 'required|string',
'outcomes' => 'required|string',
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
]);
return redirect()->route('faculty.dashboard')->with('status', 'Response submitted successfully');
} catch (\Exception $e) {
// Handle the exception and provide an error message
return back()->withErrors('An error occurred while submitting your response: ' . $e->getMessage());
// Combine start date and time
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
// Handle the file upload
$proofPath = null;
if ($request->hasFile('proof')) {
$originalName = $request->file('proof')->getClientOriginalName();
$username = auth()->user()->name;
$fileName = $username . '_' . $originalName;
// Extract year from start_date
$year = date('Y', strtotime($validated['start_date']));
// Create path structure: year/faculty_name
$folderPath = 'proofs/' . $year . '/' . $username . '/Iv_organised';
// Store file in the specified path
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
}
// Save the response to the database
IvOrganised::create([
'faculty_id' => auth()->user()->id,
'start_date' => $startDateTime,
'end_date' => $endDateTime,
'company_name' => $validated['company_name'],
'company_address' => $validated['company_address'],
'resource_person_name' => $validated['resource_person_name'],
'resource_person_contact_details' => $validated['resource_person_contact_details'],
'target_audience' => $validated['target_audience'],
'student_year' => $validated['student_year'],
'number_of_participants' => $validated['number_of_participants'],
'objective' => $validated['objective'],
'outcomes' => $validated['outcomes'],
'department_id' => auth()->user()->department->id,
'proof' => $proofPath,
]);
return redirect()->route('faculty.dashboard')->with('status', 'Industrial Visit details submitted successfully');
} catch (\Exception $e) {
// Handle the exception and provide an error message
return back()->withErrors('An error occurred while submitting your response: ' . $e->getMessage());
}
}
}
}