diff --git a/app/Http/Controllers/FacultyController.php b/app/Http/Controllers/FacultyController.php index 83cc97a..feba68b 100644 --- a/app/Http/Controllers/FacultyController.php +++ b/app/Http/Controllers/FacultyController.php @@ -36,7 +36,10 @@ class FacultyController extends Controller // Handle the file upload $proofPath = null; if ($request->hasFile('proof')) { - $proofPath = $request->file('proof')->store('proofs', 'public'); + $originalName = $request->file('proof')->getClientOriginalName(); + $username = auth()->user()->name; + $fileName = $username . '_' . $originalName; + $proofPath = $request->file('proof')->storeAs('proofs', $fileName, 'public'); } // Save the response to the database @@ -51,8 +54,8 @@ class FacultyController extends Controller return redirect()->route('faculty.dashboard')->with('status', 'Response submitted successfully'); } catch (\Exception $e) { - // Dump the error and stop execution for debugging - dd($e->getMessage()); + // Handle the exception and provide an error message + return back()->withErrors('An error occurred while submitting your response: ' . $e->getMessage()); } } }