Skip to content

Commit

Permalink
Edit update
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-muti-420 committed Apr 4, 2024
1 parent 2483cdd commit cf28e72
Show file tree
Hide file tree
Showing 6 changed files with 6,334 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app/Http/Controllers/Assessment/AssessmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,13 @@ public function storeEmployee(User $user, assessment $assessment, jcp $jcp)
return redirect()->route('dashboard', ['user' => $user, 'assessment' => $assessment, 'jcp' => $jcp])
->with('success', 'Answers submitted successfully!');
}
public function update(Request $request, $id)
{
$assessment = Assessment::find($id);

// Validate and update the assessment...
$assessment->update($request->all());

return redirect()->route('assessments.index');
}
}
11 changes: 7 additions & 4 deletions app/Http/Controllers/System/AssessmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public function show(string $id)
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
public function edit($id)
{
$assesment = assessment::findOrFail($id);
return view('directories.assessment.edit', compact('assesment'));
// Retrieve the assessment based on the ID
$assessment = Assessment::findOrFail($id);

// Pass the $assessment variable to the view
return view('directories.assessments.edit', compact('assessment'));
}

/**
Expand All @@ -58,7 +61,7 @@ public function update(Request $request, string $id)
{
$assessment = assessment::findOrFail($id);
$assessment->update($request->all());
return redirect()->route('directories.assessment.index');
return redirect()->route('directories.assessments.index');
}

/**
Expand Down
21 changes: 21 additions & 0 deletions resources/views/directories/assessments/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<x-app-layout>
<div class="mt-6 max-w-lg mx-auto">
<form action="{{ route('directories.assessments.update', $assessment->id) }}" method="POST">
@method('PUT')
@csrf

<div class="mb-4">
<label for="assessment_title" class="block text-sm font-medium text-gray-700">Assessment Name</label>
<input type="text" name="assessment_title" id="assessment_title" value="{{ $assessment->assessment_title }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
</div>

<!-- Add more fields as needed -->

<div class="mt-4 flex justify-center">
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Update Assessment
</button>
</div>
</form>
</div>
</x-app-layout>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</x-slot>
<x-slot name="content">
<!-- Directory Management -->
<x-dropdown-link href="#">
<x-dropdown-link href="{{ route('assessments.edit', ['assessment' => $assessment->id]) }}">
Edit
</x-dropdown-link>
<x-dropdown-link href="#" wire:click="deleteAssessment({{ $assessment->id }})" class="text-red-500">
Expand Down
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
Route::get('/user-assessment/{user}', [AssessmentController::class, 'index'])->name('user-assessment');
Route::get('/user-assessment/{user}/{assessment}', [AssessmentController::class, 'show'])->name('user-assessment.show');
Route::post('/user-assessment/{user}/{assessment}/{jcp}', [AssessmentController::class, 'storeEmployee'])->name('user-assessment.storeEmployee');


Route::get('/directories/assessments', [AssessmentController::class, 'index'])->name('directories.assessments.index');
Route::put('/directories/assessments/{id}', [AssessmentController::class, 'update'])->name('directories.assessments.update');
//Skill Internal API Routes

Route::resource('/assessments', SystemAssessmentController::class);
Expand Down
Loading

0 comments on commit cf28e72

Please sign in to comment.