Skip to content

Commit

Permalink
Merge pull request sebastianbergmann#108 from sheby460/chumaBranch
Browse files Browse the repository at this point in the history
Chuma branch
  • Loading branch information
sheby460 authored Jul 25, 2024
2 parents fe53a41 + 0ac0b6a commit 9f5fa9a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
8 changes: 4 additions & 4 deletions app/Http/Controllers/LanguageKnowledgeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(){

}
}
14 changes: 9 additions & 5 deletions app/Http/Controllers/UserFamilyDetailsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,23 @@ 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',
'DOB' => 'required|date',
'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');
Expand Down Expand Up @@ -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.');

}
Expand Down
3 changes: 1 addition & 2 deletions resources/views/family-details/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!-- resources/views/profile/show.blade.php -->

@extends('layouts.template')

Expand All @@ -23,7 +22,7 @@

<div class="col">
<div class="row">

<p>famil details</p>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/language/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class="active nav-link">Language</a> </li>
<td>{{ $knowledge->writing }}</td>
<td>
<!-- Edit and Delete Icons -->
<a href="{{ route('language_knowledge.index', $knowledge->id) }}" class="text-primary" title="Edit">
<a href="{{ route('language_knowledge.edit', $knowledge->id) }}" class="text-primary" title="Edit">
<i class="fa fa-edit"></i>
</a>
<a href="#" class="text-danger ms-2 delete-btn" data-id="{{ $knowledge->id }}" title="Delete">
Expand Down Expand Up @@ -181,9 +181,9 @@ class="active nav-link">Language</a> </li>
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!",
Expand Down
4 changes: 4 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
Route::put('/family-details', [UserFamilyDetailsController::class, 'edit'])->name('family-details.edit');
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');
Route::post('/health', [HealthDetailsController::class, 'addHealthData'])->name('health-details.addHealthData');
Expand All @@ -92,6 +94,8 @@

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');
Expand Down

0 comments on commit 9f5fa9a

Please sign in to comment.