From aac73f100fa71446b90dfd11e4562ef4da705472 Mon Sep 17 00:00:00 2001 From: sheby460 <59543240+sheby460@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:05:46 +0300 Subject: [PATCH] chuma logics --- .../LanguageKnowledgeController.php | 8 +- .../UserFamilyDetailsController.php | 14 +- resources/views/family-details/edit.blade.php | 187 ++---------------- .../views/family-details/index.blade.php | 2 +- resources/views/language/index.blade.php | 6 +- routes/web.php | 4 + 6 files changed, 42 insertions(+), 179 deletions(-) diff --git a/app/Http/Controllers/LanguageKnowledgeController.php b/app/Http/Controllers/LanguageKnowledgeController.php index 382eaac..ea4d7da 100644 --- a/app/Http/Controllers/LanguageKnowledgeController.php +++ b/app/Http/Controllers/LanguageKnowledgeController.php @@ -139,15 +139,15 @@ public function destroy($id) if ($languageKnowledge->userId != Auth::id()) { return redirect()->route('language_knowledge.index')->with('error', 'Unauthorized access.'); } - + $languageKnowledge->delete(); // Soft delete by setting delete_status to 1 - $languageKnowledge->delete_status = 1; - $languageKnowledge->save(); + // $languageKnowledge->delete_status = 1; + // $languageKnowledge->save(); return redirect()->route('language_knowledge.index')->with('success', 'Language knowledge deleted successfully.'); } public function jaribu(){ - + } } diff --git a/app/Http/Controllers/UserFamilyDetailsController.php b/app/Http/Controllers/UserFamilyDetailsController.php index cf978d3..d7fb79f 100644 --- a/app/Http/Controllers/UserFamilyDetailsController.php +++ b/app/Http/Controllers/UserFamilyDetailsController.php @@ -49,13 +49,15 @@ public function addFamilyData(Request $request) // Show form to edit a family member's details public function edit($id) { + // dd(123); $familyDetail = UserFamilyDetails::findOrFail($id); - return view('family-details.edit', compact('familyDetail')); + return view('family-details.edit',compact('familyDetail')); } // Update family member's details public function editData(Request $request, $id) { + $request->validate([ 'full_name' => 'required|string', 'relationship' => 'required|string', @@ -63,7 +65,7 @@ public function editData(Request $request, $id) 'phone_number' => 'nullable|string', 'occupation' => 'nullable|string', ]); - + // dd(1234); $familyDetail = UserFamilyDetails::findOrFail($id); $familyDetail->full_name = $request->input('full_name'); $familyDetail->relationship = $request->input('relationship'); @@ -93,9 +95,11 @@ public function deleteFamilyData(string $id){ ]); } - $familyDetail->update([ - 'delete_status' => 1 - ]); + // $familyDetail->update([ + // 'delete_status' => 1 + // ]); + $familyDetail->delete(); + return redirect()->back()->with('success', 'Family detail deleted successfully.'); } diff --git a/resources/views/family-details/edit.blade.php b/resources/views/family-details/edit.blade.php index d732362..13a82b9 100644 --- a/resources/views/family-details/edit.blade.php +++ b/resources/views/family-details/edit.blade.php @@ -1,173 +1,28 @@ - - @extends('layouts.template') -@section('breadcrumb') - @include('sweetalert::alert') +@section('content') +
+

Edit Family Member Details

+
+ @csrf + @method('PUT') + + + + + + + + + -
-
- + + - -
-
+ + -
-
-
-
-
-
-
-
-
-
- Profile Picture - - @csrf - - -
-
-
-
-
-

{{ $user->username }} -

-

{{ $user->email }}

-

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

-
- -
-
-
-
Joined 09 July 2024
-
-
- -
-
- -
- @csrf - @method('PATCH') - -
- -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
-
-
-
- -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
+ +
@endsection diff --git a/resources/views/family-details/index.blade.php b/resources/views/family-details/index.blade.php index cb74039..4ec7e5c 100644 --- a/resources/views/family-details/index.blade.php +++ b/resources/views/family-details/index.blade.php @@ -140,7 +140,7 @@ class="nav-link">Language {{ $detail->DOB }} {{ $detail->occupation }} - diff --git a/resources/views/language/index.blade.php b/resources/views/language/index.blade.php index fa31a79..f830745 100644 --- a/resources/views/language/index.blade.php +++ b/resources/views/language/index.blade.php @@ -145,7 +145,7 @@ class="active nav-link">Language {{ $knowledge->writing }} - + @@ -181,9 +181,9 @@ class="active nav-link">Language document.querySelectorAll('.delete-btn').forEach(button => { button.addEventListener('click', function (event) { event.preventDefault(); // Prevent default link behavior - + const id = this.getAttribute('data-id'); - + Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", diff --git a/routes/web.php b/routes/web.php index 1a5be84..612bca7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -79,6 +79,8 @@ Route::get('/family-details', [UserFamilyDetailsController::class, 'index'])->name('family-details.index'); Route::post('/family-details', [UserFamilyDetailsController::class, 'addFamilyData'])->name('family-details.addFamilyData'); Route::delete('/family-details/{id}', [UserFamilyDetailsController::class, 'destroy'])->name('family-details.destroy'); +Route::put('/family-details/{id}', [UserFamilyDetailsController::class, 'editData'])->name('family-details.editData'); +Route::get('/family-details/{id}/edit', [UserFamilyDetailsController::class, 'edit'])->name('family-details.edit'); Route::get('/health-details', [HealthDetailsController::class, 'index'])->name('health-details.index'); @@ -90,6 +92,8 @@ 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'); +Route::get('/language-knowledge/{id}/edit', [LanguageKnowledgeController::class, 'edit'])->name('language.edit'); + // Route::post('family-details', UserFamilyDetailsController::class); // Route::post('/healthDetails', [UserFamilyDetailsController::class, 'addHealthData'])->name('healthDetails.addHealthData');