$row[0], 'password' => $row[1], 'estado' => $row[2], 'inicio' => \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[3]), 'vencimiento' => \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row[4]), 'servicio_id' => $row[5], ]); $cuenta->save(); // AquĆ­ realizamos operaciones similares a las cuentas manuales if ($row[2] === 'activo') { $servicioPantallas = Servicio::find($row[5])->pantallas; $cuentasPendientes = Pendientes::where('estado', 'pendiente') ->where('servicio_id', $row[5]) ->take($servicioPantallas) ->get(); foreach ($cuentasPendientes as $i => $cuentaPendiente) { $historial_cuenta = new Historial_cuenta(); $historial_cuenta->historial_id = $cuentaPendiente->historial_id; $historial_cuenta->cuenta_id = $cuenta->id; $historial_cuenta->perfil = $i + 1; $historial_cuenta->save(); $cuentaPendiente->update(['estado' => 'cerrado']); } } return $cuenta; } public function headingRow(): int { return 1; } public function batchSize(): int { return 1000; } public function chunkSize(): int { return 1000; } public function getDateFormats(): array { return [ 'Y-m-d', ]; } }