Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Post Meta #572

Open
noplanman opened this issue Aug 18, 2021 · 3 comments
Open

Delete Post Meta #572

noplanman opened this issue Aug 18, 2021 · 3 comments

Comments

@noplanman
Copy link

  • Corcel Version: 5.0
  • Laravel 8.55.0
  • PHP Version: 8.0.9
  • Database Driver & Version: MariaDB 10.6

What is the proper way to delete post meta?

I'm talking about removing the meta item completely, not just setting it null with ->saveMeta!

@kayobruno
Copy link

Hi @noplanman, I created a PR that help you with this functionality

@noplanman
Copy link
Author

@kayobruno Nice, hope it gets merged! 🤞

@josedarci
Copy link

To properly delete a post meta item using Corcel, you can use the deleteMeta() method. Here's an example:

$post = Post::find($postId);
$post->deleteMeta('meta_key');

In the above code, replace $postId with the actual ID of the post you want to delete the meta from. The 'meta_key' parameter should be replaced with the key of the meta item you want to delete.

The deleteMeta() method will remove the specified meta item completely from the post. It does not just set it to null like saveMeta() does.

Make sure you have the necessary permissions and authentication to delete the meta item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants