Reputation: 2656
I currently have a pivot table (pending invites) joining a groups table and contacts table. There are 4 columns:
id | group_id | contact_id | email
email field is simply the email id of the contact involved. I have a situation where I need to remove a pending invite when I know the group_id and the corresponding email, but not the contact id. The standard detach function:
$groups->contacts()->detach($contact_id);
requires the contact id to be supplied. Is there a workaround to this?
Upvotes: 0
Views: 91
Reputation: 40909
You can just manually remove selected rows from the pivot table:
\DB::table('contacts_groups')
->whereGroupId($groupId)
->whereEmail($email)
->delete();
Upvotes: 1