I am building a blog website with Laravel. Right now I can create, edit and delete posts. But the problem is when I delete the post, it deletes from the database but the thumbnail image remains in the public folder.
how do I delete the image from the public folder?
Here is my delete function.
public function destroy($id) {
$post = Post::findOrFail($id);
// Delete the thumbnail
// $thumbnail = public_path("uploads/{$post->thumbnail}");
$post->delete();
return redirect('admin/posts')->with('message', 'Post deleted successfully!');
}