diff --git a/app/Http/Controllers/CcbrtRelationController.php b/app/Http/Controllers/CcbrtRelationController.php index 8c11ba8..8535a8a 100644 --- a/app/Http/Controllers/CcbrtRelationController.php +++ b/app/Http/Controllers/CcbrtRelationController.php @@ -4,7 +4,8 @@ use Illuminate\Http\Request; use App\Models\CcbrtRelation; -use App\Models\User; // Make sure to import the User model +use App\Models\User; +use App\Models\Departments; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; @@ -18,10 +19,12 @@ class CcbrtRelationController extends Controller public function index() { $user = Auth::user(); + $departments = Departments::all(); + $relations = CcbrtRelation::where('userId', $user->id)->get(); // Fetch the authenticated user's data $user = User::find($user->id); - return view('ccbrt_relation.index', compact('user')); + return view('ccbrt_relation.index', compact('user', 'departments', 'relations')); } /** diff --git a/app/Http/Controllers/LanguageKnowledgeController.php b/app/Http/Controllers/LanguageKnowledgeController.php index 8ba0766..f081fc5 100644 --- a/app/Http/Controllers/LanguageKnowledgeController.php +++ b/app/Http/Controllers/LanguageKnowledgeController.php @@ -3,8 +3,146 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Models\User; +use App\Models\LanguageKnowledge; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Validator; class LanguageKnowledgeController extends Controller { - // + /** + * Display a listing of the language knowledge for the authenticated user. + * + * @return \Illuminate\Http\Response + */ + 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. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return view('language_knowledge.create'); + } + + /** + * Store a newly created language knowledge in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(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', + ]); + + if ($validator->fails()) { + return redirect()->back()->withErrors($validator)->withInput(); + } + + LanguageKnowledge::create([ + 'userId' => Auth::id(), + 'language' => $request->input('language'), + 'speaking' => $request->input('speaking'), + 'reading' => $request->input('reading'), + 'writing' => $request->input('writing'), + 'delete_status' => 0, // Assuming delete_status is used for soft deletes + ]); + + return redirect()->route('language_knowledge.index')->with('success', 'Language knowledge added successfully.'); + } + + /** + * Show the form for editing the specified language knowledge. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $languageKnowledge = LanguageKnowledge::findOrFail($id); + + // Check if the authenticated user owns this language knowledge + if ($languageKnowledge->userId != Auth::id()) { + return redirect()->route('language_knowledge.index')->with('error', 'Unauthorized access.'); + } + + return view('language_knowledge.edit', compact('languageKnowledge')); + } + + /** + * Update the specified language knowledge in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $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', + ]); + + if ($validator->fails()) { + return redirect()->back()->withErrors($validator)->withInput(); + } + + $languageKnowledge = LanguageKnowledge::findOrFail($id); + + // Check if the authenticated user owns this language knowledge + if ($languageKnowledge->userId != Auth::id()) { + return redirect()->route('language_knowledge.index')->with('error', 'Unauthorized access.'); + } + + $languageKnowledge->language = $request->input('language'); + $languageKnowledge->speaking = $request->input('speaking'); + $languageKnowledge->reading = $request->input('reading'); + $languageKnowledge->writing = $request->input('writing'); + $languageKnowledge->save(); + + return redirect()->route('language_knowledge.index')->with('success', 'Language knowledge updated successfully.'); + } + + /** + * Remove the specified language knowledge from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $languageKnowledge = LanguageKnowledge::findOrFail($id); + + // Check if the authenticated user owns this language knowledge + if ($languageKnowledge->userId != Auth::id()) { + return redirect()->route('language_knowledge.index')->with('error', 'Unauthorized access.'); + } + + // Soft delete by setting delete_status to 1 + $languageKnowledge->delete_status = 1; + $languageKnowledge->save(); + + return redirect()->route('language_knowledge.index')->with('success', 'Language knowledge deleted successfully.'); + } } diff --git a/resources/views/ccbrt_relation/index.blade.php b/resources/views/ccbrt_relation/index.blade.php index 6e0206a..9d20463 100644 --- a/resources/views/ccbrt_relation/index.blade.php +++ b/resources/views/ccbrt_relation/index.blade.php @@ -75,56 +75,80 @@ function handleProfilePictureChange(input) {
-
-
-
+
+
+
-
- Add CCBRT Relation -
-
- -
+ @csrf -
-
+
- - +
- +
+
- - +
- -
+
- - +
- +
+
- - +
-
- +
@@ -132,6 +156,31 @@ function handleProfilePictureChange(input) {
+
+ +

Existing Relations

+
+ + + + + + + + + + + @foreach ($relations as $relation) + + + + + + + @endforeach + +
NamesRelationDepartmentPosition
{{ $relation->names }}{{ $relation->relation }}{{ $relation->department }}{{ $relation->position }}
+
diff --git a/resources/views/family-details copy 2/create.blade.php b/resources/views/family-details copy 2/create.blade.php deleted file mode 100644 index 5237e0f..0000000 --- a/resources/views/family-details copy 2/create.blade.php +++ /dev/null @@ -1,80 +0,0 @@ -
- @csrf - -
- -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
-
-
-
- -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
-
- -
-
-
\ No newline at end of file diff --git a/resources/views/family-details copy 2/edit.blade.php b/resources/views/family-details copy 2/edit.blade.php deleted file mode 100644 index d732362..0000000 --- a/resources/views/family-details copy 2/edit.blade.php +++ /dev/null @@ -1,173 +0,0 @@ - - -@extends('layouts.template') - -@section('breadcrumb') - @include('sweetalert::alert') - -
-
- - - -
-
- -
-
-
-
-
-
-
-
-
-
- Profile Picture - -
-
-
-
-
-

{{ $user->username }} -

-

{{ $user->email }}

-

{{ $user->department->name }}

-
- -
-
-
-
Joined 09 July 2024
-
-
- -
-
- -
- @csrf - @method('PATCH') - -
- -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
-
-
-
- -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-@endsection diff --git a/resources/views/family-details copy 2/show.blade.php b/resources/views/family-details copy 2/show.blade.php deleted file mode 100644 index e69de29..0000000 diff --git a/resources/views/family-details/index.blade.php b/resources/views/family-details/index.blade.php index 18505a5..a3c8c05 100644 --- a/resources/views/family-details/index.blade.php +++ b/resources/views/family-details/index.blade.php @@ -74,9 +74,21 @@ function handleProfilePictureChange(input) {
@@ -113,38 +125,46 @@ function handleProfilePictureChange(input) {

Add Family Details

-
+ @csrf - +
- +
- +
- +
- +
- +
- +
- +
diff --git a/resources/views/family-details/show.blade.php b/resources/views/family-details/show.blade.php deleted file mode 100644 index e69de29..0000000 diff --git a/resources/views/health-details/index.blade.php b/resources/views/health-details/index.blade.php index 0456786..932a978 100644 --- a/resources/views/health-details/index.blade.php +++ b/resources/views/health-details/index.blade.php @@ -72,12 +72,13 @@ function handleProfilePictureChange(input) {
-
+
+
@@ -143,7 +144,8 @@ function handleProfilePictureChange(input) {
+ name="insur_name" + value="{{ old('insur_name') }}">
diff --git a/resources/views/health-details/show.blade.php b/resources/views/health-details/show.blade.php deleted file mode 100644 index e69de29..0000000 diff --git a/resources/views/ccbrt_relation/show.blade.php b/resources/views/language/create.blade.php similarity index 100% rename from resources/views/ccbrt_relation/show.blade.php rename to resources/views/language/create.blade.php diff --git a/resources/views/language/edit.blade.php b/resources/views/language/edit.blade.php new file mode 100644 index 0000000..3a38b51 --- /dev/null +++ b/resources/views/language/edit.blade.php @@ -0,0 +1,273 @@ + + +@extends('layouts.template') + +@section('breadcrumb') + @include('sweetalert::alert') + +
+
+ + + +
+
+ +
+
+
+
+
+
+
+
+
+
+ Profile Picture + + @csrf + + +
+
+
+
+
+

{{ $user->username }} +

+

{{ $user->email }}

+

{{ $user->department->name }}

+
+ +
+
+
+
Joined 09 July 2024
+
+
+ +
+
+ +
+
+
+ @csrf +
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+
+
+
+
+
+@endsection diff --git a/resources/views/family-details copy 2/index.blade.php b/resources/views/language/index.blade.php similarity index 63% rename from resources/views/family-details copy 2/index.blade.php rename to resources/views/language/index.blade.php index 18505a5..b8a11f8 100644 --- a/resources/views/family-details copy 2/index.blade.php +++ b/resources/views/language/index.blade.php @@ -20,6 +20,7 @@
+
@@ -50,7 +51,8 @@
-

{{ $user->username }}

+

{{ $user->username }} +

{{ $user->email }}

{{ $user->department->name }}

@@ -72,82 +74,99 @@ function handleProfilePictureChange(input) {
-
-
-
-

Family Details

- @if (session('success')) -
- {{ session('success') }} +
+ @csrf + +
+
+
+ +
- @endif - - - - - - - - - - - - @foreach ($familyData as $detail) - - - - - - - - @endforeach - -
Full NameRelationshipMobileDate of BirthOccupation
{{ $detail->full_name }}{{ $detail->relationship }}{{ $detail->phone_number }}{{ $detail->DOB }}{{ $detail->occupation }}
-
-
-

Add Family Details

- - @csrf - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
- - +
+
+ +
- + + +
+ +

Language Knowledge

+
+ + + + + + + + + + + @forelse ($languageKnowledge as $knowledge) + + + + + + + @empty + + + + @endforelse + +
LanguageSpeakingReadingWriting
{{ $knowledge->language }}{{ $knowledge->speaking }}{{ $knowledge->reading }}{{ $knowledge->writing }}
No language + knowledge found.
+
-
diff --git a/resources/views/user_profile/index.blade.php b/resources/views/user_profile/index.blade.php index 623102e..f6d980c 100644 --- a/resources/views/user_profile/index.blade.php +++ b/resources/views/user_profile/index.blade.php @@ -75,7 +75,7 @@ function handleProfilePictureChange(input) {
@@ -481,10 +482,6 @@ class="accordion-collapse collapse"
- - - --}} - {{--
diff --git a/routes/web.php b/routes/web.php index fe90352..b3f2172 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,6 +25,7 @@ use App\Http\Controllers\PrivilegeLevelController; use App\Http\Controllers\RequestApproveController; use App\Http\Controllers\ChangeManagementController; +use App\Http\Controllers\LanguageKnowledgeController; use App\Http\Controllers\NhifQualificationController; use App\Http\Controllers\UserFamilyDetailsController; @@ -82,6 +83,8 @@ Route::get('/relation-details', [CcbrtRelationController::class, 'index'])->name('relation-details.index'); Route::post('/relation', [CcbrtRelationController::class, 'addRelationData'])->name('relation-details.addRelationData'); +Route::get('/language-knowledge', [LanguageKnowledgeController::class, 'index'])->name('language_knowledge.index'); +Route::post('/language-knowledge', [LanguageKnowledgeController::class, 'addLanguageKnowledge'])->name('language_knowledge.add'); // Route::post('family-details', UserFamilyDetailsController::class);