validate([ 'titre' => 'required|string|max:255', 'contenu' => 'required|string', ]); $article = Article::create($validated); return redirect('/'); } /** * Display the specified resource. */ public function show(string $id) { return Article::findOrFail($id); } /** * Update the specified resource in storage. */ public function update(Request $request, string $id) { $validated = $request->validate([ 'titre' => 'required|string|max:255', 'contenu' => 'required|string', ]); $article = Article::findOrFail($id); $article->update($validated); return response()->json($article, 200); } /** * Remove the specified resource from storage. */ public function destroy(string $id) { $article = Article::findOrFail($id); $article->delete(); return redirect('/'); } }