Lina

How to delete post_tags and tag in a same instruction

Posted 1 year ago by Lina

Hi friends,

I have this code and I want to do on the best way:

    public function deleteTag(Request $request)
    {
        Tag::find($request->id)->post_tags()->delete();
        return Tag::destroy($request->id);
    }

Delete the post_tags and the tags

post_tags (tag_id, post_id) tags(id, tag_name)

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.