/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Obtener las bases de datos
     $bds = BaseDatosCadeco::all();
     $this->output->progressStart(count($bds));
     foreach ($bds as $bd) {
         $this->output->newLine();
         $this->info('Revirtiendo la ultima migracion en ' . $bd->nombre);
         $this->config->set('database.connections.' . $this->argument('connection') . '.database', $bd->nombre);
         $this->call('migrate:rollback', ['--database' => $this->argument('connection')]);
         DB::disconnect($this->argument('connection'));
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Obtener las bases de datos
     $bds = BaseDatosCadeco::all();
     $this->output->progressStart(count($bds));
     foreach ($bds as $bd) {
         $this->output->newLine();
         $this->info('Ejecutando migraciones en ' . $bd->nombre);
         $this->config->set('database.connections.' . $this->argument('connection') . '.database', $bd->nombre);
         if ($this->option('path')) {
             $this->call('migrate', ['--database' => $this->argument('connection'), '--path' => $this->option('path')]);
         }
         $this->call('migrate', ['--database' => $this->argument('connection')]);
         if ($this->option('seed')) {
             $this->call('db:seed', ['--force' => true, '--database' => $this->argument('connection')]);
         }
         DB::disconnect($this->argument('connection'));
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }
 /**
  * Obtiene las obras de un usuario cadeco de todas las bases de datos definidas
  *
  * @param $idUsuario
  * @return Collection|Obra
  */
 public function getObras($idUsuario)
 {
     $obrasUsuario = new Collection();
     $basesDatos = BaseDatosCadeco::where('activa', true)->orderBy('nombre')->get();
     foreach ($basesDatos as $bd) {
         $this->config->set('database.connections.cadeco.database', $bd->nombre);
         $usuarioCadeco = $this->getUsuarioCadeco($idUsuario);
         $obras = $this->getObrasUsuario($usuarioCadeco);
         foreach ($obras as $obra) {
             $obra->databaseName = $bd->nombre;
             $obrasUsuario->push($obra);
         }
         DB::disconnect('cadeco');
     }
     $perPage = 10;
     $currentPage = Paginator::resolveCurrentPage();
     $currentPage = $currentPage ? $currentPage : 1;
     $offset = $currentPage * $perPage - $perPage;
     $paginator = new LengthAwarePaginator($obrasUsuario->slice($offset, $perPage), $obrasUsuario->count(), $perPage);
     return $paginator;
 }