json(Candidate::all()->toJSON()); } public function show($id) { $candidate = Candidate::friend($id); if ($candidate) { return response()->json($candidate->toArray()); } else { return response()->json(['message' => 'Кандидант не найден'], 404); } } public function create(Request $request) { $title = $request->get(key:'title'); $description = $request->get(key:'description'); $creatorUser = 1; $candidate = new Candidate(); $candidate->title = $title; $candidate->description =$description; $candidate->craetor_user_id =$creatorUser; $candidate->save(); return response()->json($candidate->toJson()); } }