Skip to content

Commit

Permalink
Merge pull request sebastianbergmann#88 from sheby460/chumaBranch
Browse files Browse the repository at this point in the history
chuma commit
  • Loading branch information
sheby460 authored Jul 17, 2024
2 parents 6ecf0c1 + b3b6eb9 commit 906d3b2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 25 deletions.
25 changes: 20 additions & 5 deletions app/Http/Controllers/CcbrtRelationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.');
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/IctAccessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions app/Http/Controllers/LanguageKnowledgeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()) {
Expand All @@ -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.');
Expand Down
5 changes: 3 additions & 2 deletions resources/views/ccbrt_relation/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class="nav-link">User Info</a></li>
class="active nav-link">Family Details</a></li>
<li class="nav-item"><a href="{{ route('health-details.index') }}"
class=" nav-link">Health Details</a></li>
<li class="nav-item"><a href="{{ route('relation-details.index') }}"
<li class="nav-item"><a href="{{ route('ccbrt_relation.index') }}"
class="active nav-link">CCBRT Reation</a></li>
<li class="nav-item"><a href="{{ route('language_knowledge.index') }}"
class="nav-link">Language</a> </li>
Expand All @@ -98,8 +98,9 @@ class="nav-link">Language</a> </li>
<div class="card">
<div class="card-body">
<form method="POST"
action="{{ route('relation-details.addRelationData') }}">
action="{{ route('ccbrt_relation.addRelationData') }}">
@csrf
<input type="hidden" name="userId" value="{{ Auth::id() }}">
<div class="row">
<div class="col-12 col-md-3">
<div class="form-group">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/language/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class="nav-link">User Info</a></li>
class="nav-link">Family Details</a></li>
<li class="nav-item"><a href="{{ route('health-details.index') }}"
class=" nav-link">Health Details</a></li>
<li class="nav-item"><a href="{{ route('relation-details.index') }}"
<li class="nav-item"><a href="{{ route('ccbrt_relation.index') }}"
class="nav-link">CCBRT Reation</a></li>
<li class="nav-item"><a href="{{ route('language_knowledge.index') }}"
class="active nav-link">Language</a> </li>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/user_profile/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ function handleProfilePictureChange(input) {
class="nav-link">Family Details</a></li>
<li class="nav-item"><a href="{{ route('health-details.index') }}"
class="nav-link">Health Details</a></li>
<li class="nav-item"><a href="{{ route('relation-details.index') }}"
<li class="nav-item"><a href="{{ route('ccbrt_relation.index') }}"
class="nav-link">CCBRT Reation</a></li>
<li class="nav-item"><a href="{{ route('language_knowledge.index') }}"
<li class="nav-item"><a href="{{ route('language_knowledge.index') }}"
class="nav-link">Language</a> </li>

<li class="nav-item"><a href="#policies" class="nav-link"
data-bs-toggle="tab">Policies</a></li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 906d3b2

Please sign in to comment.