feat: year wise proof sorting

This commit is contained in:
Sallu9007
2025-03-23 16:32:26 +05:30
parent 8c4e18e702
commit 2e5f02fdea

View File

@@ -46,13 +46,22 @@ class FacultyController extends Controller
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_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']}")); $endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
// Handle the file upload
// Handle the file upload // Handle the file upload
$proofPath = null; $proofPath = null;
if ($request->hasFile('proof')) { if ($request->hasFile('proof')) {
$originalName = $request->file('proof')->getClientOriginalName(); $originalName = $request->file('proof')->getClientOriginalName();
$username = auth()->user()->name; $username = auth()->user()->name;
$fileName = $username . '_' . $originalName; $fileName = $username . '_' . $originalName;
$proofPath = $request->file('proof')->storeAs('proofs', $fileName, 'public');
// Extract year from start_date
$year = date('Y', strtotime($validated['start_date']));
// Create path structure: year/faculty_name
$folderPath = 'proofs/' . $year . '/' . $username;
// Store file in the specified path
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
} }
// Save the response to the database // Save the response to the database