删除数据透视表行而不知道其中一个外键

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?

You can just manually remove selected rows from the pivot table:

\DB::table('contacts_groups')
  ->whereGroupId($groupId)
  ->whereEmail($email)
  ->delete();