validate([ "test_id" => "required|integer", "student_id" => "required|integer" ]); AssignedTests::create($validated); return redirect(route("tests.edit", [ "test" => Test::where("id", $validated["test_id"])->first() ])); } /** * Display the specified resource. */ public function show($assigned_student) { // } /** * Show the form for editing the specified resource. */ public function edit($assigned_student) { $obj = AssignedTests::where("id", $assigned_student); $obj->update([ "allowed" => "1" ]); $test_id = $obj->first()->test_id; return redirect(route("tests.edit", [ "test" => Test::where("id", $test_id)->first() ])); } /** * Update the specified resource in storage. */ public function update(Request $request, AssignedTests $assigned_student) { // $test->update($validated); } /** * Remove the specified resource from storage. */ public function destroy($assigned_student) { $obj = AssignedTests::where("id", $assigned_student); $test_id = $obj->first()->test_id; $obj->delete(); return redirect(route("tests.edit", [ "test" => Test::where("id", $test_id)->first() ])); } }