id; $clientContact->invoice_invitations()->delete(); $clientContact->quote_invitations()->delete(); $clientContact->credit_invitations()->delete(); $clientContact->recurring_invoice_invitations()->delete(); //ensure entity state is preserved InvoiceInvitation::withTrashed()->where('client_contact_id', $client_contact_id)->cursor()->each(function ($invite){ if($invite->invoice()->doesnthave('invitations')) $invite->invoice->service()->createInvitations(); }); QuoteInvitation::withTrashed()->where('client_contact_id', $client_contact_id)->cursor()->each(function ($invite){ if($invite->quote()->doesnthave('invitations')) $invite->quote->service()->createInvitations(); }); RecurringInvoiceInvitation::withTrashed()->where('client_contact_id', $client_contact_id)->cursor()->each(function ($invite){ if($invite->recurring_invoice()->doesnthave('invitations')) $invite->recurring_invoice->service()->createInvitations(); }); CreditInvitation::withTrashed()->where('client_contact_id', $client_contact_id)->cursor()->each(function ($invite){ if($invite->credit()->doesnthave('invitations')) $invite->credit->service()->createInvitations(); }); } /** * Handle the client contact "restored" event. * * @param ClientContact $clientContact * @return void */ public function restored(ClientContact $clientContact) { } /** * Handle the client contact "force deleted" event. * * @param ClientContact $clientContact * @return void */ public function forceDeleted(ClientContact $clientContact) { // } }