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