diff --git a/app/Http/Controllers/CcbrtRelationController.php b/app/Http/Controllers/CcbrtRelationController.php index 8535a8a..e5b5d8d 100644 --- a/app/Http/Controllers/CcbrtRelationController.php +++ b/app/Http/Controllers/CcbrtRelationController.php @@ -8,6 +8,7 @@ use App\Models\Departments; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; +use RealRashid\SweetAlert\Facades\Alert; class CcbrtRelationController extends Controller { @@ -38,17 +39,31 @@ public function addRelationData(Request $request) $validator = Validator::make($request->all(), [ 'userId' => 'required|exists:users,id', 'names' => 'required|string|max:255', - 'position' => 'required|string|max:255', - 'department' => 'required|string|max:255', - 'relation' => 'required|string|max:255', + 'position' => 'required', + 'department' => 'required', // Ensure deptId is required + 'relation' => 'required', ]); if ($validator->fails()) { - return redirect()->back()->withErrors($validator)->withInput(); + return response()->json([ + 'status' => 400, + 'error' => $validator->errors() + ]); } - CcbrtRelation::create($request->all()); + // Create the relation record + $relate = CcbrtRelation::create([ + 'userId' => $request->input('userId'), + 'names' => $request->input('names'), + 'position' => $request->input('position'), + 'department' => $request->input('department'), // Ensure deptId is saved correctly + 'relation' => $request->input('relation'), + ]); + + // Optionally, add a success alert + Alert::success('Relationship added successful', 'CCbrt Related user added'); + // Redirect with success message return redirect()->route('ccbrt_relation.index')->with('success', 'Relation details added successfully.'); } } diff --git a/app/Http/Controllers/IctAccessController.php b/app/Http/Controllers/IctAccessController.php index 9ae954b..516e2f2 100644 --- a/app/Http/Controllers/IctAccessController.php +++ b/app/Http/Controllers/IctAccessController.php @@ -152,10 +152,10 @@ public function store(Request $request) ]); \Log::info('Workflow history forwarded for approval'); - + // dd(1235); // Success alert and redirect Alert::success('IT access form request submitted successfully', 'IT access Request Added'); - return redirect()->route('myrequest.index')->with('success', 'ICT Access Resource created successfully.'); + return redirect()->route('form.index')->with('success', 'ICT Access Resource created successfully.'); }); } catch (\Exception $e) { // Log the exact error message for better debugging diff --git a/app/Http/Controllers/LanguageKnowledgeController.php b/app/Http/Controllers/LanguageKnowledgeController.php index f081fc5..837349e 100644 --- a/app/Http/Controllers/LanguageKnowledgeController.php +++ b/app/Http/Controllers/LanguageKnowledgeController.php @@ -18,16 +18,16 @@ class LanguageKnowledgeController extends Controller public function index() { $user = Auth::user(); - + if (!$user) { return redirect()->route('login')->with('error', 'Unauthorized access.'); } - + $languageKnowledge = LanguageKnowledge::where('userId', $user->id)->get(); - + return view('language.index', compact('languageKnowledge', 'user')); } - + /** * Show the form for creating a new language knowledge entry. @@ -45,13 +45,14 @@ public function create() * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store(Request $request) + public function addLanguageKnowledge(Request $request) { $validator = Validator::make($request->all(), [ - 'language' => 'required|string|max:255', - 'speaking' => 'required|string|max:255', - 'reading' => 'required|string|max:255', - 'writing' => 'required|string|max:255', + 'language'=>'required', + 'speaking'=>'required', + 'reading'=>'required', + 'writing'=>'required', + 'userId'=>'required|exists:users,id', ]); if ($validator->fails()) { @@ -64,7 +65,7 @@ public function store(Request $request) 'speaking' => $request->input('speaking'), 'reading' => $request->input('reading'), 'writing' => $request->input('writing'), - 'delete_status' => 0, // Assuming delete_status is used for soft deletes + 'delete_status' => 0, ]); return redirect()->route('language_knowledge.index')->with('success', 'Language knowledge added successfully.'); diff --git a/resources/views/ccbrt_relation/index.blade.php b/resources/views/ccbrt_relation/index.blade.php index 9d20463..54b4126 100644 --- a/resources/views/ccbrt_relation/index.blade.php +++ b/resources/views/ccbrt_relation/index.blade.php @@ -83,7 +83,7 @@ class="nav-link">User Info class="active nav-link">Family Details - @@ -98,8 +98,9 @@ class="nav-link">Language
+ action="{{ route('ccbrt_relation.addRelationData') }}"> @csrf +
diff --git a/resources/views/language/index.blade.php b/resources/views/language/index.blade.php index b8a11f8..26103c2 100644 --- a/resources/views/language/index.blade.php +++ b/resources/views/language/index.blade.php @@ -83,7 +83,7 @@ class="nav-link">User Info class="nav-link">Family Details - diff --git a/resources/views/user_profile/index.blade.php b/resources/views/user_profile/index.blade.php index f6d980c..8696f2d 100644 --- a/resources/views/user_profile/index.blade.php +++ b/resources/views/user_profile/index.blade.php @@ -83,11 +83,11 @@ function handleProfilePictureChange(input) { class="nav-link">Family Details - - - + diff --git a/routes/web.php b/routes/web.php index b3f2172..d4293d3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -81,8 +81,8 @@ -Route::get('/relation-details', [CcbrtRelationController::class, 'index'])->name('relation-details.index'); -Route::post('/relation', [CcbrtRelationController::class, 'addRelationData'])->name('relation-details.addRelationData'); +Route::get('/ccbrt_relation', [CcbrtRelationController::class, 'index'])->name('ccbrt_relation.index'); +Route::post('/relation', [CcbrtRelationController::class, 'addRelationData'])->name('ccbrt_relation.addRelationData'); Route::get('/language-knowledge', [LanguageKnowledgeController::class, 'index'])->name('language_knowledge.index'); Route::post('/language-knowledge', [LanguageKnowledgeController::class, 'addLanguageKnowledge'])->name('language_knowledge.add');