CommentsController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Comment;
  4. use App\Post;
  5. use Illuminate\Http\Request;
  6. class CommentsController extends Controller
  7. {
  8. /**
  9. * Show the form for creating a new resource.
  10. *
  11. * @return \Illuminate\Http\Response
  12. */
  13. public function create()
  14. {
  15. //
  16. }
  17. /**
  18. * Remove the specified resource from storage.
  19. *
  20. * @param int $id
  21. *
  22. * @return \Illuminate\Http\Response
  23. */
  24. public function destroy($id)
  25. {
  26. //
  27. }
  28. /**
  29. * Show the form for editing the specified resource.
  30. *
  31. * @param int $id
  32. *
  33. * @return \Illuminate\Http\Response
  34. */
  35. public function edit($id)
  36. {
  37. //
  38. }
  39. /**
  40. * Display a listing of the resource.
  41. *
  42. * @return \Illuminate\Http\Response
  43. */
  44. public function index()
  45. {
  46. //
  47. }
  48. /**
  49. * Display the specified resource.
  50. *
  51. * @param int $id
  52. *
  53. * @return \Illuminate\Http\Response
  54. */
  55. public function show($id)
  56. {
  57. //
  58. }
  59. /**
  60. * Store a newly created resource in storage.
  61. *
  62. * @param \Illuminate\Http\Request $request
  63. *
  64. * @return \Illuminate\Http\Response
  65. */
  66. public function store(Post $post, Request $request)
  67. {
  68. $this->validate($request, ['body' => 'required|min:2']);
  69. $post->addComment($request->get('body'));
  70. // return redirect("/posts/{$post->id}");
  71. return back();
  72. }
  73. /**
  74. * Update the specified resource in storage.
  75. *
  76. * @param \Illuminate\Http\Request $request
  77. * @param int $id
  78. *
  79. * @return \Illuminate\Http\Response
  80. */
  81. public function update(Request $request, $id)
  82. {
  83. //
  84. }
  85. }