Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SensvanAert committed Nov 9, 2023
2 parents 713b6d5 + 618fe9e commit c925dc0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Binary file removed code/webapp.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions code/webapp/app/Http/Controllers/QuestionListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\QuestionList;
use App\Models\TreePart;
use App\Models\Question;
use App\Models\QuestionUserList;
use App\Models\Answer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
Expand Down Expand Up @@ -110,6 +111,7 @@ public function destroy($id)

$questionList = QuestionList::find($id);
$questions = Question::where('question_list_id', $questionList->id)->get();
QuestionUserList::where('question_list_id', $questionList->id)->delete();
foreach ($questions as $question) {
$answers = Answer::where('question_id', $question->id)->get();
foreach($answers as $answer){
Expand Down
6 changes: 5 additions & 1 deletion code/webapp/app/Http/Controllers/SurveyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public function update(Request $request, $id)
public function destroy($id)
{
Gate::authorize("allowAdmin");
//
$survey = InfoContent::find($id);
$survey->delete();

$msg = "Survey Deleted successful! ";
return redirect("surveys/")->with("msg", $msg);
}
}
17 changes: 13 additions & 4 deletions code/webapp/resources/views/surveys/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@
<tbody>
@foreach ($surveys as $survey)
<tr class="font-normal">
<td class="border border-[#f4f4f4] py-2 px-6 w-full">{{ $survey->title }}</td>
<td class="border border-[#f4f4f4] py-2 px-6 w-full">{{ $survey->url }}</td>
<td class="border border-[#f4f4f4] py-2 px-6 w-full">
<a href="{{ route('surveys.edit', $survey->id) }}" class="text-wb-blue">Bewerk</a>
<td class="border border-[#f4f4f4] py-2 px-6 w-1/6">{{ $survey->title }}</td>
<td class="border border-[#f4f4f4] py-2 px-6 w-2/3 break-all">{{ $survey->url }}</td>
<td class="border border-[#f4f4f4] py-2 px-6 w-1/6">
<form action="{{ route('surveys.destroy', $survey->id) }}" method="post">
@csrf
@method('delete')

<a href="{{ route('surveys.edit', $survey->id) }}" class="text-wb-blue">Bewerk</a>
<span>|</span>

<button type="submit" class="text-wb-blue"
onclick="return confirm('Ben je zeker dat je deze tevredenheidsmeting wilt verwijderen?');">Verwijder</button>
</form>
</td>
</tr>
@endforeach
Expand Down

0 comments on commit c925dc0

Please sign in to comment.