contacts->pluck('id'))->diff($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, 'user_id' => auth()->user()->id ] ); $update_contact->fill($contact); $update_contact->save(); }); } }