From fccdf1e923535e80ebd8795e0005fffbc45befc8 Mon Sep 17 00:00:00 2001 From: Sens van Aert Date: Tue, 24 Oct 2023 15:40:22 +0200 Subject: [PATCH 1/2] Vragenlijst controller voor api en tevredensheid meting met naam ipv id --- .../Api/QuestionListController.php | 301 ++++++++++++++++++ .../app/Http/Controllers/ClientController.php | 3 +- 2 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 code/webapp/app/Http/Controllers/Api/QuestionListController.php diff --git a/code/webapp/app/Http/Controllers/Api/QuestionListController.php b/code/webapp/app/Http/Controllers/Api/QuestionListController.php new file mode 100644 index 00000000..08b6ccc2 --- /dev/null +++ b/code/webapp/app/Http/Controllers/Api/QuestionListController.php @@ -0,0 +1,301 @@ +json([ + "status" => true, + "questions" => [$question], + ]); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(StoreQuestionRequest $request) + { + $question = Question::create($request->all()); + + return response()->json( + [ + "status" => true, + "message" => "Question created succesfully", + "question" => $question, + ], + 200 + ); + } + + /** + * Display the specified resource. + * + * @param \App\Models\Question $question + * @return \Illuminate\Http\Response + */ + public function show(Question $question) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\Question $question + * @return \Illuminate\Http\Response + */ + public function edit(Question $question) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Question $question + * @return \Illuminate\Http\Response + */ + public function update(StoreQuestionRequest $request, Question $question) + { + $question->update($request->all()); + + return response()->json( + [ + "status" => true, + "message" => "Question updated succesfully", + "question" => $question, + ], + 200 + ); + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\Question $question + * @return \Illuminate\Http\Response + */ + public function destroy(Question $question) + { + $question->delete(); + + return response()->json( + [ + "status" => true, + "message" => "Question deleted succesfully", + ], + 200 + ); + } +} diff --git a/code/webapp/app/Http/Controllers/ClientController.php b/code/webapp/app/Http/Controllers/ClientController.php index 1596d8b1..b95bd2db 100644 --- a/code/webapp/app/Http/Controllers/ClientController.php +++ b/code/webapp/app/Http/Controllers/ClientController.php @@ -147,7 +147,8 @@ public function edit($id) public function sendSurvey($id) { $url = InfoContent::where("info_id", 1)->first()->url; - $url = $url . $id; + $user = User::find($id); + $url = $url . $user->surname . ' ' . $user->firstname; User::find($id)->notify(new Survey($url)); User::find($id)->update(["survey" => now()]); From 5d83fd5de0b61afc836fef020f1701166d25da33 Mon Sep 17 00:00:00 2001 From: Sens van Aert Date: Thu, 26 Oct 2023 14:08:24 +0200 Subject: [PATCH 2/2] added api for QuestionList --- .../Api/QuestionListController.php | 64 ++++++------------- code/webapp/routes/api.php | 4 ++ 2 files changed, 23 insertions(+), 45 deletions(-) diff --git a/code/webapp/app/Http/Controllers/Api/QuestionListController.php b/code/webapp/app/Http/Controllers/Api/QuestionListController.php index 08b6ccc2..7c10d247 100644 --- a/code/webapp/app/Http/Controllers/Api/QuestionListController.php +++ b/code/webapp/app/Http/Controllers/Api/QuestionListController.php @@ -199,51 +199,42 @@ class QuestionListController extends Controller */ public function index() { - $question = Question::all(); + $questionLists = QuestionList::all(); return response()->json([ "status" => true, - "questions" => [$question], + "questionLists" => [$questionLists], ]); } /** - * Show the form for creating a new resource. + * Display the specified resource. * + * @param \App\Models\QuestionList $questionList * @return \Illuminate\Http\Response */ - public function create() + public function show(QuestionList $questionList) { // } /** - * Store a newly created resource in storage. + * Show the form for creating a new resource. * - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store(StoreQuestionRequest $request) + public function create() { - $question = Question::create($request->all()); - - return response()->json( - [ - "status" => true, - "message" => "Question created succesfully", - "question" => $question, - ], - 200 - ); + // } /** - * Display the specified resource. + * Store a newly created resource in storage. * - * @param \App\Models\Question $question + * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function show(Question $question) + public function store(StoreQuestionRequest $request) { // } @@ -251,10 +242,10 @@ public function show(Question $question) /** * Show the form for editing the specified resource. * - * @param \App\Models\Question $question + * @param \App\Models\QuestionList $questionList * @return \Illuminate\Http\Response */ - public function edit(Question $question) + public function edit(QuestionList $questionList) { // } @@ -263,39 +254,22 @@ public function edit(Question $question) * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request - * @param \App\Models\Question $question + * @param \App\Models\QuestionList $questionList * @return \Illuminate\Http\Response */ - public function update(StoreQuestionRequest $request, Question $question) + public function update(StoreQuestionListRequest $request, QuestionList $questionList) { - $question->update($request->all()); - - return response()->json( - [ - "status" => true, - "message" => "Question updated succesfully", - "question" => $question, - ], - 200 - ); + // } /** * Remove the specified resource from storage. * - * @param \App\Models\Question $question + * @param \App\Models\QuestionList $questionList * @return \Illuminate\Http\Response */ - public function destroy(Question $question) + public function destroy(QuestionList $questionList) { - $question->delete(); - - return response()->json( - [ - "status" => true, - "message" => "Question deleted succesfully", - ], - 200 - ); + // } } diff --git a/code/webapp/routes/api.php b/code/webapp/routes/api.php index ca04d3d9..a82f2d75 100644 --- a/code/webapp/routes/api.php +++ b/code/webapp/routes/api.php @@ -8,6 +8,7 @@ use App\Http\Controllers\Api\SectionController; use App\Http\Controllers\Api\RoleController; use App\Http\Controllers\Api\QuestionController; +use App\Http\Controllers\Api\QuestionListController; use App\Http\Controllers\Api\AnswerController; use App\Http\Controllers\Api\UserController; use App\Http\Controllers\Api\DepartmentListController; @@ -45,6 +46,7 @@ "section" => SectionController::class, "role" => RoleController::class, "question" => QuestionController::class, + "questionList" => QuestionListController::class, "treeParts" => TreePartController::class, "answer" => AnswerController::class, "users" => UserController::class, @@ -57,6 +59,8 @@ Route::get("infoContent", [InfoContentController::class, "index"]); Route::get("section", [SectionController::class, "index"]); Route::get("treeParts", [TreePartController::class, "index"]); +Route::get("question", [QuestionController::class, "index"]); +Route::get("questionList", [QuestionListController::class, "index"]); Route::post("/auth/register", [AuthController::class, "createUser"]); Route::post("/auth/login", [AuthController::class, "loginUser"]);