Fix: User with same name have same folders in storage
This commit is contained in:
@@ -150,13 +150,14 @@ class FacultyController extends Controller
|
|||||||
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;
|
||||||
|
$userId = auth()->user()->id;
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Extract year from start_date
|
// Extract year from start_date
|
||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name
|
// Create path structure: year/faculty_name
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . 'Activities-Attended';
|
$folderPath = 'proofs/' . $year . '/' . $userId . '_' . $username . '/Activities-Attended';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -221,13 +222,14 @@ class FacultyController extends Controller
|
|||||||
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;
|
||||||
|
$userId = auth()->user()->id;
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Extract year from start_date
|
// Extract year from start_date
|
||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name
|
// Create path structure: year/faculty_name
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . 'Activities-Organised';
|
$folderPath = 'proofs/' . $year . '/' . $userId . '_' . $username . '/Activities-Organised';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -292,13 +294,14 @@ class FacultyController extends Controller
|
|||||||
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;
|
||||||
|
$userId = auth()->user()->id;
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Extract year from start_date
|
// Extract year from start_date
|
||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name
|
// Create path structure: year/faculty_name
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . '/Iv_organised';
|
$folderPath = 'proofs/' . $year . '/' . $userId . '_' . $username . '/Iv_organised';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -361,13 +364,14 @@ class FacultyController extends Controller
|
|||||||
if ($request->hasFile('paper_file')) {
|
if ($request->hasFile('paper_file')) {
|
||||||
$originalName = $request->file('paper_file')->getClientOriginalName();
|
$originalName = $request->file('paper_file')->getClientOriginalName();
|
||||||
$username = auth()->user()->name;
|
$username = auth()->user()->name;
|
||||||
|
$userId = auth()->user()->id;
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Extract year from start_date
|
// Extract year from start_date
|
||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name/Publications
|
// Create path structure: year/faculty_name/Publications
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . '/Publications';
|
$folderPath = 'proofs/' . $year . '/' . $userId . '_' . $username . '/Publications';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$paperFilePath = $request->file('paper_file')->storeAs($folderPath, $fileName, 'public');
|
$paperFilePath = $request->file('paper_file')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -424,13 +428,14 @@ class FacultyController extends Controller
|
|||||||
if ($request->hasFile('proof_file')) {
|
if ($request->hasFile('proof_file')) {
|
||||||
$originalName = $request->file('proof_file')->getClientOriginalName();
|
$originalName = $request->file('proof_file')->getClientOriginalName();
|
||||||
$username = auth()->user()->name;
|
$username = auth()->user()->name;
|
||||||
|
$userId = auth()->user()->id;
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Extract year from start_date
|
// Extract year from start_date
|
||||||
$year = date('Y', strtotime($validated['date_of_publication']));
|
$year = date('Y', strtotime($validated['date_of_publication']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name/Publications
|
// Create path structure: year/faculty_name/Publications
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . '/Publications';
|
$folderPath = 'proofs/' . $year . '/' . $userId . '_' . $username . '/Publications';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofFilePath = $request->file('proof_file')->storeAs($folderPath, $fileName, 'public');
|
$proofFilePath = $request->file('proof_file')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -478,13 +483,14 @@ class FacultyController extends Controller
|
|||||||
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;
|
||||||
|
$userId = auth()->user()->id;
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Extract year from start_date
|
// Extract year from start_date
|
||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name/Publications
|
// Create path structure: year/faculty_name/Publications
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . '/External Engagement';
|
$folderPath = 'proofs/' . $year . '/' . $userId . '_' . $username . '/External Engagement';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -532,13 +538,14 @@ class FacultyController extends Controller
|
|||||||
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;
|
||||||
|
$userId = auth()->user()->id;
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Extract year from start_date
|
// Extract year from start_date
|
||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name/Publications
|
// Create path structure: year/faculty_name/Publications
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . '/Online Course';
|
$folderPath = 'proofs/' . $year . '/' . $userId . '_' . $username . '/Online Course';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -587,13 +594,14 @@ class FacultyController extends Controller
|
|||||||
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;
|
||||||
|
$userId = auth()->user()->id;
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Extract year from start_date
|
// Extract year from start_date
|
||||||
$year = date('Y', strtotime($validated['date_of_submission']));
|
$year = date('Y', strtotime($validated['date_of_submission']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name/Publications
|
// Create path structure: year/faculty_name/Publications
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . '/Patents';
|
$folderPath = 'proofs/' . $year . '/' . $userId . '_' . $username . '/Patents';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
$proofFilePath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
|
|||||||
Reference in New Issue
Block a user