Update (admin): Add delete post forever

This commit is contained in:
2023-08-02 00:21:00 +08:00
parent 7c1f02012c
commit 7eafdbd8b3
5 changed files with 26 additions and 1 deletions

View File

@@ -37,6 +37,21 @@ public function edit(Request $request, $post_id)
return redirect()->back()->with('error', 'Post does not exist.');
}
public function delete(Request $request, $post_id)
{
$post = Post::find($post_id);
if (! is_null($post)) {
$post_categories = PostCategory::where('post_id', $post->id)->delete();
$post->delete();
return redirect()->back()->with('success', 'Post deleted.');
}
return redirect()->back()->with('error', 'Post does not exist.');
}
public function indexing(Request $request, $post_id)
{
$post = Post::find($post_id);