tenant = $this->option("tenant"); setup_db_connection(); config(['database.connections.mysql-tenant.database' => config('json.prefix_db') . "_ente{$this->tenant}"]); DB::purge('mysql-tenant'); $tenant = Tenant::find($this->tenant); $collections = Conservazione::where("stato", "<", 20)->get(); foreach($collections as $collection) { if ($collection->items()->count() < 1) { $this->info("Retrieving files for package #{$collection->codice}"); GetFilesJob::dispatchSync($this->tenant, $collection->codice); } if($collection->items()->count() > 0) { $preservation = new PreservationClass($tenant->codice, $collection->codice); $preservation->enableDebugging(); if($collection->items()->where('stato', '<>', '20')->count() < 1) { $this->info("Checking the status of package #{$collection->codice}"); $preservation->checkPreservationStatus(); } else { $this->info("Sending package #{$collection->codice}"); $preservation->pushCollection(); } } } return 0; } }