contacts->pluck('id'))->diffKeys($contacts->pluck('id'))->each(function($contact){ ClientContact::destroy($contact); }); /* Set first record to primary - always*/ $contacts = $contacts->sortBy('is_primary'); $contacts->first(function($contact){ $contact['is_primary'] = true; }); //loop and update/create contacts $contacts->each(function ($contact) use ($client){ $update_contact = ClientContact::firstOrNew( ['id' => $contact['id']], [ 'client_id' => $client->id, 'company_id' => $client->company_id ] ); $update_contact->fill($contact); $update_contact->save(); }); } }