0
I created a command in Laravel to run at a certain time and now I need to get the result only of the affected lines. The method I used makes a count of the entire loop.
$count = 0;
foreach ($contacts as $contact) {
if (empty($contact->nome))
continue;
if (empty($contact->cnpj))
continue;
$contato = $company->clientes()->updateOrCreate([
'cpf_cnpj' => $contact->cnpj
], [
'cpf_cnpj' => $contact->cnpj,
'company_id' => $company->id,
'nome' => $contact->nome,
'fantasia' => $contact->fantasia,
'tipo' => $contact->tipo,
'ie_rg' => $contact->ie_rg,
'endereco' => $contact->endereco,
'numero' => $contact->numero,
'bairro' => $contact->bairro,
'cep' => $contact->cep,
'cidade' => $contact->cidade,
'complemento' => $contact->complemento,
'uf' => $contact->uf,
'fone_cell' => $contact->fone,
'email' => $contact->email,
'limiteCredito' => $contact->limiteCredito,
'situacao' => $contact->situacao,
'contribuinte' => $contact->contribuinte,
'dataNascimento' => isset($contact->dataNascimento[0]) ? $contact->dataNascimento : null
]);
$count++;
$contato->save();
}