option('tenant') ?? $this->ask('What is Tenant id?'); $this->tenant = Tenant::find($tenant); if (! $this->tenant) { $this->error('Invalid Tenant ID. Please try again.'); } } while (! $this->tenant); setup_db_connection($this->tenant->codice); $ente = new \ente(); $ente->excludeConnector = true; $ente->init($this->tenant->dominio); if(empty($ente->codice)) { throw new InvalidArgumentException("Failed to initialize EnteClass with: {$this->tenant->dominio}"); } global $pdo; $pdo->setConnessioneEnte($this->tenant->codice); if($ente->hasModulo('conservazione') && Contratti::count() > 0) { foreach(Contratti::select("codice", "stato")->cursor() as $contratto) { $this->line("Processing contract #{$contratto["codice"]}"); $ente->checkConservazione("stipula", $contratto["codice"], $contratto["stato"], $ente->codice); } } return 0; } }