where("classcode", $classes_code)->delete(); } public function get($classes_code) { $object = DB::table("usercache")->where("classcode", $classes_code)->first(); return $object; } public function add(Request $request) { $classes_code = $request->classes_code; $classes = DB::table("classes")->where("classes_code", $classes_code)->first(); if(is_null($classes)) { return response()->json(['message' => 'Nie ma takich zajęć'], 400); } else { $cache = DB::table("usercache")->where("classcode", $classes_code)->first(); if(!is_null($cache)) { return response()->json(['message' => 'Użytkownik w cache'], 500); } } DB::table("usercache")->insert([ "name" => $request->student_name, "surname" => $request->student_surname, "classcode" => $request->classes_code, "index" => $request->student_index ]); return response()->json(['message' => 'ADDED'], 200); } }