Feat: External Engegement, Online Course and Patents
This commit is contained in:
@@ -6,7 +6,10 @@ use Illuminate\Http\Request;
|
||||
use App\Models\ActivitiesAttended;
|
||||
use App\Models\ActivitiesOrganised;
|
||||
use App\Models\BooksPublished;
|
||||
use App\Models\ExternalEngagement;
|
||||
use App\Models\IvOrganised;
|
||||
use App\Models\OnlineCourse;
|
||||
use App\Models\Patent;
|
||||
use App\Models\Publication;
|
||||
|
||||
class FacultyController extends Controller
|
||||
@@ -72,6 +75,41 @@ class FacultyController extends Controller
|
||||
return view('booksPublished.index');
|
||||
}
|
||||
|
||||
public function ExternalEngagementForm()
|
||||
{
|
||||
// Logic to show the response form
|
||||
return view('faculty.externalEngagement-form');
|
||||
}
|
||||
|
||||
public function viewExternalEngagementResponses()
|
||||
{
|
||||
return view('externalEngagement.index');
|
||||
}
|
||||
|
||||
public function OnlineCoursesForm()
|
||||
{
|
||||
// Logic to show the response form
|
||||
return view('faculty.onlineCourses-form');
|
||||
}
|
||||
|
||||
public function viewOnlineCoursesResponses()
|
||||
{
|
||||
return view('onlineCourses.index');
|
||||
}
|
||||
|
||||
public function PatentsForm()
|
||||
{
|
||||
// Logic to show the response form
|
||||
return view('faculty.patents-form');
|
||||
}
|
||||
|
||||
public function viewPatentsResponses()
|
||||
{
|
||||
return view('patents.index');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function ActivitiesAttendedFormResponse(Request $request)
|
||||
{
|
||||
try {
|
||||
@@ -410,4 +448,170 @@ class FacultyController extends Controller
|
||||
return back()->withErrors(['error' => 'An error occurred: ' . $e->getMessage()])->withInput();
|
||||
}
|
||||
}
|
||||
public function ExternalEngagementFormResponse(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
try {
|
||||
// Validate the request data
|
||||
$validated = $request->validate([
|
||||
'activity' => 'required|string',
|
||||
'activity_description' => 'required|string',
|
||||
'inviting_organization' => 'required|string',
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'required|date',
|
||||
'num_days' => 'required|integer',
|
||||
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip'
|
||||
]);
|
||||
|
||||
// Handle the file upload
|
||||
$proofFilePath = 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/Publications
|
||||
$folderPath = 'proofs/' . $year . '/' . $username . '/External Engagement';
|
||||
|
||||
// Store file in the specified path
|
||||
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||
}
|
||||
// dd($proofFilePath);
|
||||
|
||||
// Save the response to the database
|
||||
ExternalEngagement::create([
|
||||
'department_id' => auth()->user()->department->id,
|
||||
'activity' => $validated['activity'],
|
||||
'activity_description' => $validated['activity_description'],
|
||||
'inviting_organization' => $validated['inviting_organization'],
|
||||
'start_date' => $validated['start_date'],
|
||||
'end_date' => $validated['end_date'],
|
||||
'num_days' => $validated['num_days'],
|
||||
'proof' => $proofFilePath,
|
||||
'faculty_id' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
return redirect()->route('faculty.dashboard')->with('status', 'External Engagement details submitted successfully');
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||
return back()->withErrors(['error' => 'External Engagement not found.']);
|
||||
} catch (\Illuminate\Validation\ValidationException $e) {
|
||||
return back()->withErrors($e->validator)->withInput();
|
||||
} catch (\Exception $e) {
|
||||
return back()->withErrors(['error' => 'An error occurred: ' . $e->getMessage()])->withInput();
|
||||
}
|
||||
}
|
||||
public function OnlineCoursesFormResponse(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
try {
|
||||
// Validate the request data
|
||||
$validated = $request->validate([
|
||||
'course' => 'required|string',
|
||||
'offered_by' => 'required|string',
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'required|date',
|
||||
'num_days' => 'required|integer',
|
||||
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
|
||||
]);
|
||||
|
||||
// Handle the file upload
|
||||
$proofFilePath = 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/Publications
|
||||
$folderPath = 'proofs/' . $year . '/' . $username . '/Online Course';
|
||||
|
||||
// Store file in the specified path
|
||||
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||
}
|
||||
// dd($proofFilePath);
|
||||
|
||||
// Save the response to the database
|
||||
OnlineCourse::create([
|
||||
'department_id' => auth()->user()->department->id,
|
||||
'course' => $validated['course'],
|
||||
'offered_by' => $validated['offered_by'],
|
||||
'start_date' => $validated['start_date'],
|
||||
'end_date' => $validated['end_date'],
|
||||
'num_days' => $validated['num_days'],
|
||||
'proof' => $proofFilePath,
|
||||
'faculty_id' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
return redirect()->route('faculty.dashboard')->with('status', 'Online Course details submitted successfully');
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||
return back()->withErrors(['error' => 'Online Course not found.']);
|
||||
} catch (\Illuminate\Validation\ValidationException $e) {
|
||||
return back()->withErrors($e->validator)->withInput();
|
||||
} catch (\Exception $e) {
|
||||
return back()->withErrors(['error' => 'An error occurred: ' . $e->getMessage()])->withInput();
|
||||
}
|
||||
}
|
||||
public function PatentsFormResponse(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
try {
|
||||
// Validate the request data
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string',
|
||||
'investigator' => 'required|string',
|
||||
'application_no' => 'required|string',
|
||||
'type' => 'required|string',
|
||||
'date_of_submission' => 'required|date',
|
||||
'date_of_filling' => 'required|date',
|
||||
'status' => 'required|string',
|
||||
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
|
||||
]);
|
||||
|
||||
// Handle the file upload
|
||||
$proofFilePath = 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['date_of_submission']));
|
||||
|
||||
// Create path structure: year/faculty_name/Publications
|
||||
$folderPath = 'proofs/' . $year . '/' . $username . '/Patents';
|
||||
|
||||
// Store file in the specified path
|
||||
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||
}
|
||||
// dd($proofFilePath);
|
||||
|
||||
|
||||
// Save the response to the database
|
||||
Patent::create([
|
||||
'department_id' => auth()->user()->department->id,
|
||||
'title' => $validated['title'],
|
||||
'investigator' => $validated['investigator'],
|
||||
'application_no' => $validated['application_no'],
|
||||
'type' => $validated['type'],
|
||||
'date_of_submission' => $validated['date_of_submission'],
|
||||
'date_of_filling' => $validated['date_of_filling'],
|
||||
'status' => $validated['status'],
|
||||
'proof' => $proofFilePath,
|
||||
'faculty_id' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
return redirect()->route('faculty.dashboard')->with('status', 'Patent/Copyright details submitted successfully');
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||
return back()->withErrors(['error' => 'Patent/Copyright not found.']);
|
||||
} catch (\Illuminate\Validation\ValidationException $e) {
|
||||
return back()->withErrors($e->validator)->withInput();
|
||||
} catch (\Exception $e) {
|
||||
return back()->withErrors(['error' => 'An error occurred: ' . $e->getMessage()])->withInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user