From 222fbb59cac1d3f797257099d25836bb93f39d0f Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 11 Mar 2022 20:33:02 +0000 Subject: [PATCH] Added ability to edit your post --- app/Http/Controllers/Community.php | 17 +++++++++++++++++ resources/views/community.blade.php | 29 +++++++++++++++++++++++++---- routes/web.php | 3 +++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Community.php b/app/Http/Controllers/Community.php index e3e876c5..a9169272 100644 --- a/app/Http/Controllers/Community.php +++ b/app/Http/Controllers/Community.php @@ -137,4 +137,21 @@ public function leaveSubject($id) //POST REQUEST return redirect(route('community')); } + + public function updatePost($id, Request $request) + { + $post = Post::query()->where('posts.id', $id); + + $title = $request->input('title'); + $body = $request->input('body'); + + $post->update( + [ + 'title' => $title, + 'body' => $body + ] + ); + + return redirect(route('community')); + } } diff --git a/resources/views/community.blade.php b/resources/views/community.blade.php index 0d20bd2c..0fa32407 100644 --- a/resources/views/community.blade.php +++ b/resources/views/community.blade.php @@ -256,7 +256,7 @@ class="bg-transparent absolute inset-x-0 bottom-0 h-0.5">