$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) { $servicioName = $cuentaPendiente->servicio->nombre; $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']); $historial_cuenta->historial->vendedor->notify(new NotificacionPendiente($servicioName)); $consulta = new Notificacion(); $consulta->remitente_id = Auth::user()->id; $consulta->destinatario_id = $historial_cuenta->historial->vendedor_id; $consulta->titulo = "Licencia asignada para $servicioName"; $consulta->descripcion = 'La licencia de ' . $servicioName . ' ha sido activada y ahora puedes utilizar tu cuenta sin problemas. Tus credenciales son: correo: ' . $historial_cuenta->cuenta->correo . ' contraseƱa: ' . $historial_cuenta->cuenta->password; $consulta->estado = true; $consulta->todos = false; $consulta->save(); } } 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', ]; } }