From ba57f19319356543bba5bcd118220b4736eba2b8 Mon Sep 17 00:00:00 2001 From: Ghostie Date: Wed, 21 Aug 2024 20:23:16 -0500 Subject: [PATCH] added routing for the comments --- app/Http/Controllers/CommentController.php | 8 +++++++- app/Http/Controllers/PostController.php | 3 ++- resources/views/posts/show.blade.php | 4 ++-- routes/web.php | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index e0f3306..a0ccc75 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -6,5 +6,11 @@ use Illuminate\Http\Request; class CommentController extends Controller { - // + public function store() + { + // validate + + // store + dd("commenting..."); + } } diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php index 57e9dc1..05f8f12 100644 --- a/app/Http/Controllers/PostController.php +++ b/app/Http/Controllers/PostController.php @@ -53,7 +53,8 @@ class PostController extends Controller implements HasMiddleware public function show(User $user, Post $post) { return view("posts.show", [ - "post" => $post + "post" => $post, + "user" => $user ]); } } diff --git a/resources/views/posts/show.blade.php b/resources/views/posts/show.blade.php index 5db835a..4058fc5 100644 --- a/resources/views/posts/show.blade.php +++ b/resources/views/posts/show.blade.php @@ -5,7 +5,7 @@ @endsection @section('content') -
+
{{ $post->title }} @@ -29,7 +29,7 @@ @auth

Add a new Comment

-
+ @csrf
diff --git a/routes/web.php b/routes/web.php index 6f70e22..b4d8746 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@ name("posts.crea Route::post("/posts", [PostController::class, "store"])->name("posts.store"); Route::get("/{user:username}/posts/{post}", [PostController::class, "show"])->name("posts.show"); +Route::post("/{user:username}/posts/{post}", [CommentController::class, "store"])->name("comment.store"); + Route::post("/images", [ImageController::class, "store"])->name("images.store");